public NtStatus MoveFile(string oldName, string newName, bool replace, DokanFileInfo info)
        {
            /* if (replace)
             *  return NtStatus.NotImplemented;
             */
            if (oldName == newName)
            {
                return(NtStatus.Success);
            }
            if (directories.Contains(oldName))
            {
                int pathCount = oldName.Split(@"\".ToCharArray(), StringSplitOptions.RemoveEmptyEntries).Length;
                if (directories.Contains(newName) || Path.GetFileName(newName).Length > igorSevoDemands.MaxFolderNameLength) // Questionable second condition
                {
                    return(NtStatus.NotImplemented);
                }

                // New code in try/catch block
                try
                {
                    ArrayList temp = new ArrayList();
                    foreach (var x in files.Where(filePath => filePath.Key.Contains(oldName)))
                    {
                        temp.Add(x.Key);
                    }
                    foreach (string x in temp)
                    {
                        string tempString = x;
                        tempString = tempString.Replace(oldName, newName);
                        NodeLekachFile tempNode = files[x];
                        files.Remove(x);
                        files.Add(tempString, tempNode);
                    }
                    temp.Clear();
                    foreach (var x in directories.Where(filePath => filePath.Contains(oldName)))
                    {
                        temp.Add(x);
                    }
                    foreach (string x in temp)
                    {
                        string tempString = x;
                        tempString = tempString.Replace(oldName, newName);
                        directories.Remove(oldName);
                        directories.Add(tempString);
                    }
                    temp.Clear();
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.Message);
                }

                /* In fact works, throw Exception in only 1 special case
                 * directories.Add(newName);
                 * foreach (var file in files.Where(filePath => filePath.Key.StartsWith(oldName + @"\") && filePath.Key.Length > oldName.Length + 1 && filePath.Key.Split(@"\".ToCharArray(), StringSplitOptions.RemoveEmptyEntries).Length == pathCount + 1))
                 * {
                 *  files.Add(newName + @"\" + Path.GetFileName(file.Key), file.Value);
                 *  files.Remove(file.Key);
                 * }
                 * directories.Remove(oldName);
                 */
                return(NtStatus.Success);
            }
            else if (files.Keys.Contains(oldName))
            {
                if (files.Keys.Contains(newName) || Path.GetFileName(newName).Length > igorSevoDemands.MaxFilenameLength) // Questionable second condition
                {
                    return(NtStatus.NotImplemented);
                }
                files.Add(newName, files[oldName]);
                files.Remove(oldName);
                return(NtStatus.Success);
            }
            return(NtStatus.Unsuccessful);
        }
 public NtStatus CreateFile(string fileName, DokanNet.FileAccess access, FileShare share, FileMode mode, FileOptions options, FileAttributes attributes, DokanFileInfo info)
 {
     if (Path.GetFileName(fileName).Length > igorSevoDemands.MaxFilenameLength)
     {
         // throw new Exception("IgorSevoDemands: MAX FILE/FOLDER NAME LENGTH EXCEEDED!!!");
         Console.WriteLine("IgorSevoDemands: MAX FILE/FOLDER NAME LENGTH EXCEEDED!!!");
         return(NtStatus.Unsuccessful);
     }
     if (fileName == "\\")
     {
         return(NtStatus.Success);
     }
     if (access == DokanNet.FileAccess.ReadAttributes && mode == FileMode.Open)
     {
         return(NtStatus.Success);
     }
     if (mode == FileMode.CreateNew)
     {
         if (Path.GetFileName(fileName).Length > igorSevoDemands.MaxFilenameLength)
         {
             // throw new Exception("IgorSevoDemands: MAX FILE NAME LENGTH EXCEEDED!!!");
             Console.WriteLine("IgorSevoDemands: MAX FILE NAME LENGTH EXCEEDED!!!");
             return(NtStatus.Unsuccessful);
         }
         if (attributes == FileAttributes.Directory || info.IsDirectory)
         {
             if (Path.GetFileName(fileName).Length > igorSevoDemands.MaxFolderNameLength)
             {
                 // throw new Exception("IgorSevoDemands: MAX FOLDER NAME LENGTH EXCEEDED!!!");
                 Console.WriteLine("IgorSevoDemands: MAX FOLDER NAME LENGTH EXCEEDED!!!");
                 return(NtStatus.Unsuccessful);
             }
             if (fileName.Count(separator => separator == '\\') <= igorSevoDemands.MaxTreeDepth)
             {
                 directories.Add(fileName);
             }
             else
             {
                 return(NtStatus.Unsuccessful);
             }
         }
         else if (!files.Keys.Contains(fileName))
         {
             /* // Smth for debuging
              * string pathName = Path.GetFileName(fileName);
              * int pathNameLast = pathName.LastIndexOf('.');
              * string tempString = Path.GetFileName(fileName).Substring(Path.GetFileName(fileName).LastIndexOf('.') + 1);
              * int tempLength = tempString.Length;
              */
             if (Path.GetFileName(fileName).Substring(Path.GetFileName(fileName).LastIndexOf('.') + 1).Length != igorSevoDemands.FileExtensionLength)
             {
                 // throw new Exception("IgorSevoDemands: EXTENSION IS NOT LEGAL!!!");
                 Console.WriteLine("IgorSevoDemands: EXTENSION IS NOT LEGAL!!!");
                 return(NtStatus.Unsuccessful);
             }
             if (files.Where(filePath => filePath.Key.Contains(fileName.Substring(0, fileName.LastIndexOf(@"\") + 1))).Count() >= igorSevoDemands.MaxFilesPerFolder)
             {
                 // throw new Exception("IgorSevoDemands: MAX NUMBER OF FILES PER ONE FOLDER EXCEEDED!!!");
                 Console.WriteLine("IgorSevoDemands: MAX NUMBER OF FILES PER ONE FOLDER EXCEEDED!!!");
                 return(NtStatus.Unsuccessful);
             }
             NodeLekachFile newNodeLekachFile = new NodeLekachFile();
             (newNodeLekachFile.DateCreate, newNodeLekachFile.DateModified) = (DateTime.Now, DateTime.Now);
             files.Add(fileName, newNodeLekachFile);
         }
     }
     return(NtStatus.Success);
 }