public class ReadFileSharePath
{
string Path = null;
public string ReadFilePath()
{
try
{
CloudStorageAccount cloudStorageAccount = ConnectionString.GetConnectionString();
CloudFileClient cloudFileClient = cloudStorageAccount.CreateCloudFileClient();
CloudFileShare fileShare = cloudFileClient.GetShareReference("sampleimage");
if (fileShare.Exists())
{
CloudFileDirectory rootdir = fileShare.GetRootDirectoryReference();
CloudFileDirectory sampleDir = rootdir.GetDirectoryReference("sampleimage");
if (sampleDir.Exists())
{
// Get a reference to the file we created previously.
CloudFile file = sampleDir.GetFileReference("90e94676-492d-4c3c-beb2-1d8d48044e4e-.jpg");
// Ensure that the file exists.
if (file.Exists())
{
// Write the contents of the file to the console window.
//Console.WriteLine(file.DownloadTextAsync().Result);
Path = file.DownloadTextAsync().Result.ToString();
}
}
}
}
catch (Exception)
{
throw;
}
return Path;
}
}
Однако это условие if
if (sampleDir.Exists())
терпит неудачу. И управление не входит в цикл.
Я хотел бы сохранить путь к общему файловому ресурсу в хранилище таблиц Azure. Я хотел бы получить ключ раздела и ключ строки. Как мне этого добиться?
Я могу загрузить изображение в общую папку Azure, используя приведенный ниже код. [code]CloudStorageAccount cloudStorageAccount = ConnectionString.GetConnectionString(); CloudFileClient cloudFileClient = cloudStorageAccount.CreateCloudFileClient(); CloudFileShare fileShare = cloudFileClient.GetShareReference("sampleimage"); if (await fileShare.CreateIfNotExistsAsync()) { await fileShare.SetPermissionsAsync( new FileSharePermissions {
} return imageFullPath; [/code] Вот как я пытаюсь прочитать путь к файлу: [Перед вставкой в таблицу] [code]public class ReadFileSharePath { string Path = null; public string ReadFilePath() {
if (sampleDir.Exists()) { // Get a reference to the file we created previously. CloudFile file = sampleDir.GetFileReference("90e94676-492d-4c3c-beb2-1d8d48044e4e-.jpg");
// Ensure that the file exists. if (file.Exists()) { // Write the contents of the file to the console window. //Console.WriteLine(file.DownloadTextAsync().Result); Path = file.DownloadTextAsync().Result.ToString(); } } }
} catch (Exception) {
throw; } return Path;
}
} [/code] Однако это условие if
if (sampleDir.Exists())
терпит неудачу. И управление не входит в цикл. Я хотел бы сохранить путь к общему файловому ресурсу в хранилище таблиц Azure. Я хотел бы получить ключ раздела и ключ строки. Как мне этого добиться?
Я написал следующий код Python для создания токена SAS для файла, помещенного в общий каталог файлов Azure:
def getParcelFilePath(webcountyval):
filePath = f /plan/IN/{webcountyval}%20parcels.dbf
file_sas_token = generate_file_sas(...
У меня есть набор ключей строк, например
CloudTable table = cloudTableClient.GetTableReference( MyTable );
var partitionKey = PK ;
var rowKeys = new List{ RK1 , RK2 , RK3 };
теперь, если я хочу получить записи, я могу просмотреть список и для...