0
フォルダを動的に作成し、ファイルをuwp appのローカルフォルダにコピーする必要があります。フォルダ名はファイル名でなければなりません。たとえば、名前がTest01.pngのファイルをアップロードするとします。フォルダ名は 'Test01'で作成し、Test01.pngをTest01フォルダにコピーする必要があります。ファイルがすでに存在する場合は、「ファイルが既に存在し、置き換える必要があります」のような警告が表示されます。UWPのLocalFolderにフォルダを作成してファイルをコピーします
FileOpenPicker openPicker = new FileOpenPicker();
openPicker.ViewMode = PickerViewMode.Thumbnail;
openPicker.SuggestedStartLocation = PickerLocationId.Desktop;
foreach (string extension in FileExtensions.Video)
{
openPicker.FileTypeFilter.Add(extension);
}
file = await openPicker.PickSingleFileAsync();
if (file != null)
{
StorageFolder localFolder = Windows.Storage.ApplicationData.Current.LocalFolder;
await ApplicationData.Current.LocalFolder.CreateFolderAsync("Data");//need to change the folder name with filename
string desiredName = file.Name;
//should copy it to subfolder and raise alert if already exist
StorageFile newFile = await localFolder.CreateFileAsync(desiredName, CreationCollisionOption.FailIfExists);
}
ここでテストします。これに共通のルートフォルダ(「Test」という名前)を追加できますか? Localstate> Test> Test01> Test01.txtを意味します。ローカル州>テスト> Test02> Test02.txt? – nsds
sfとは何ですか? sf.CopyAsync – nsds
sfはあなたのファイルです。コードを更新しました。 「これに共通する」という言葉が何であるか分かりませんが、このコードではあなたが望むことができます。やってみて。 –