FileStore.FileStore.DeleteFile C# (CSharp) Method

DeleteFile() public method

Deletes a file.
public DeleteFile ( string path ) : void
path string The file path.
return void
        public void DeleteFile(string path)
        {
            if(path == null) {
                throw new ArgumentNullException("path");
            }

            string[] components = path.Split(Separators, StringSplitOptions.RemoveEmptyEntries);
            if(components.Length == 0) {
                return;
            }

            string fileName = components[components.Length - 1];
            StoreFolder folder = GetFolder(path.Substring(0, path.Length - fileName.Length));

            // check if the folder contains the file
            if(folder.Files.ContainsKey(fileName)) {
                Guid fileId = folder.Files[fileName];

                // remove
                folder.Files.Remove(fileName);
                files.Remove(fileId);
            }
        }