I want to create folders dynamically and need to copy files to local folder of uwp app. Folder name should be the filename. For example if I upload a file with name Test01.png. Then a folder should create with name 'Test01' and need to copy Test01.png to Test01 folder. If the file already exist it should show alert like "file already exist,need to replace".
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);
}
Here's what you could do. I've written this in notepad and did not get a chance to test this.