private string CreateNewFile(string fileNameWithExtension, CreateCollisionOption collisionOption) { string fileNamePath = Path + System.IO.Path.DirectorySeparatorChar + fileNameWithExtension; if (File.Exists(fileNamePath)) { switch (collisionOption) { case CreateCollisionOption.GenerateUniqueName: int i = 1; while (File.Exists(fileNamePath)) { fileNamePath = System.IO.Path.GetFileNameWithoutExtension(fileNameWithExtension); fileNamePath += "(" + i + ")"; fileNamePath += System.IO.Path.GetExtension(fileNameWithExtension); fileNamePath = Path + System.IO.Path.PathSeparator + fileNamePath; i++; } // File.Create(fileNamePath); break; case CreateCollisionOption.ReplaceExisting: // File.Create(fileNamePath); break; case CreateCollisionOption.FailIfExists: fileNamePath = null; break; case CreateCollisionOption.OpenIfExists: break; default: break; } } else { // File.Create(fileNamePath); } return(fileNamePath); }
internal StorageFile CreateFile(string fileNameWithExtension, CreateCollisionOption collisionOption) { string fileNamePath = CreateNewFile(fileNameWithExtension, collisionOption); return(NewStorageFile(fileNamePath)); }
internal async Task <StorageFile> CreateFileAsync(string fileNameWithExtension, CreateCollisionOption collisionOption) { return(await Task.Run(() => CreateFile(fileNameWithExtension, collisionOption))); }
private string CreateNewFile(string fileNameWithExtension, CreateCollisionOption collisionOption) { string fileNamePath = Path + System.IO.Path.DirectorySeparatorChar + fileNameWithExtension; if (File.Exists(fileNamePath)) { switch (collisionOption) { case CreateCollisionOption.GenerateUniqueName: int i = 1; while (File.Exists(fileNamePath)) { fileNamePath = System.IO.Path.GetFileNameWithoutExtension(fileNameWithExtension); fileNamePath += "(" + i + ")"; fileNamePath += System.IO.Path.GetExtension(fileNameWithExtension); fileNamePath = Path + System.IO.Path.PathSeparator + fileNamePath; i++; } // File.Create(fileNamePath); break; case CreateCollisionOption.ReplaceExisting: // File.Create(fileNamePath); break; case CreateCollisionOption.FailIfExists: fileNamePath = null; break; case CreateCollisionOption.OpenIfExists: break; default: break; } } else { // File.Create(fileNamePath); } return fileNamePath; }
internal StorageFile CreateFile(string fileNameWithExtension, CreateCollisionOption collisionOption) { string fileNamePath = CreateNewFile(fileNameWithExtension, collisionOption); return NewStorageFile(fileNamePath); }
internal async Task<StorageFile> CreateFileAsync(string fileNameWithExtension, CreateCollisionOption collisionOption) { return await Task.Run(() => CreateFile(fileNameWithExtension, collisionOption)); }