我想动态创建文件夹,需要将文件复制到uwp app的本地文件夹 . 文件夹名称应为文件名 . 例如,如果我上传名为Test01.png的文件 . 然后应创建一个名为'Test01'的文件夹,并将Test01.png复制到Test01文件夹 . 如果该文件已存在,则应显示“文件已存在,需要替换”等警告 .
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);
}
1 回答
这是你能做的 . 我在记事本中写了这个,没有机会测试这个 .