bool MakeDir() { if (SetNewDirectory) { string Tempo = Partes[NumberPart.Get()].GetCurrentPath(); Tempo += '\\' + MaKeys.GetText(); try { DirectoryInfo NewDir = Directory.CreateDirectory(@Tempo); Global.AddToLogFile(@Tempo, "Maked Directory", "Success"); Global.Attention.AddContent(MyFunc.Set(2, 1), $"Successfully Maked Directory {@Tempo}"); } catch (UnauthorizedAccessException) { Global.Attention.AddContent(MyFunc.Set(2, 1), "Access Denied"); Global.AddToLogFile(@Tempo, "Trying to make Directory", "Access Denied"); return(false); } catch (Exception) { Global.Attention.AddContent(MyFunc.Set(2, 1), "Can not make Directory"); Global.AddToLogFile(@Tempo, "Trying to make Directory", "Can not make Directory"); return(false); } SetNewDirectory = false; NameEnterer.Enabled = false; return(true); } return(false); }
public void PrepareDirectory() { //Получаем список элементов в директории по текущему пути CurrentContent.Load(MaWalker.GetPath()); //Подготавливаем границы для маркера MainMarker.Init(0, TableContent.GetKoords().Secundus + 1, ContentSizes.Secundus - 2, CurrentContent.GetLength()); Global.AddToLogFile(MaWalker.GetPath(), "New Directory Opened", "Success"); }
public void LoadFile(string Path001) { string[] FileContent = null; try { FileContent = File.ReadAllLines(@Path001); } catch (NullReferenceException) { Global.Attention.AddContent(MyFunc.Set(2, 1), "Nothing read"); Global.AddToLogFile(Path001, "Trying read file", "Nothing read"); return; } catch (FileNotFoundException) { Global.Attention.AddContent(MyFunc.Set(2, 1), "File not found"); Global.AddToLogFile(Path001, "Trying read file", "File not found"); return; } catch (UnauthorizedAccessException) { Global.Attention.AddContent(MyFunc.Set(2, 1), "Access Denied"); Global.AddToLogFile(Path001, "Trying read file", "Access Denied"); return; } catch (Exception) { Global.Attention.AddContent(MyFunc.Set(2, 1), "Can not Read File"); Global.AddToLogFile(Path001, "Trying read file", "Can not Read File"); return; } Data = new List <string>(); foreach (var Item in FileContent) { try { Data.Add(Item); //FileContent = File.ReadAllLines(Path001); } catch (NullReferenceException) { Global.Attention.AddContent(MyFunc.Set(2, 1), "Nothing read"); Global.AddToLogFile(Path001, "Trying read file", "Nothing read"); } } }
void DoCopy(string FromPath, string ToPath, string Name, Global.Types CurrentType) { string SourcePath = Path.Combine(FromPath, Name); string DestinationPath = Path.Combine(ToPath, Name); if (CurrentType == Global.Types.File) { try { File.Copy(SourcePath, DestinationPath, true); Global.AddToLogFile($"From {FromPath} To {ToPath}", $"Copied File {Name}", "Success"); Global.Attention.AddContent(MyFunc.Set(2, 1), $"Successfully Copied File {SourcePath} To {ToPath}"); } catch (UnauthorizedAccessException) { Global.Attention.AddContent(MyFunc.Set(2, 1), "Access Denied"); Global.AddToLogFile(SourcePath, "Trying to Copy File", "Access Denied"); } catch (Exception) { Global.Attention.AddContent(MyFunc.Set(2, 1), "Can not Copy File"); Global.AddToLogFile(SourcePath, "Trying to Copy File", "Can not Copy File"); } return; } if (CurrentType == Global.Types.Directory) { try { CopyDirectory(FromPath, ToPath, Name); Global.AddToLogFile($"From {FromPath} To {ToPath}", $"Copied Directory {Name}", "Success"); Global.Attention.AddContent(MyFunc.Set(2, 1), $"Successfully Copied Directory From {SourcePath} To {ToPath}"); } catch (UnauthorizedAccessException) { Global.Attention.AddContent(MyFunc.Set(2, 1), "Access Denied"); Global.AddToLogFile(SourcePath, "Trying to Copy Directory", "Access Denied"); } catch (Exception) { Global.Attention.AddContent(MyFunc.Set(2, 1), "Can not Copy Directory"); Global.AddToLogFile(SourcePath, "Trying to Copy Directory", "Can not Copy Directory"); } return; } }
void DeleteUnit(string CurrentFullName, Global.Types CurrentType) { if (CurrentType == Global.Types.File) { try { File.Delete(CurrentFullName); Global.AddToLogFile(CurrentFullName, "Deleted File", "Success"); Global.Attention.AddContent(MyFunc.Set(2, 1), $"Successfully Deleted File {CurrentFullName}"); } catch (UnauthorizedAccessException) { Global.Attention.AddContent(MyFunc.Set(2, 1), "Access Denied"); Global.AddToLogFile(CurrentFullName, "Trying to Delete File", "Access Denied"); } catch (Exception) { Global.Attention.AddContent(MyFunc.Set(2, 1), "Can not Delete File"); Global.AddToLogFile(CurrentFullName, "Trying to make Delete File", "Can not make Delete File"); } return; } if (CurrentType == Global.Types.Directory) { try { Directory.Delete(CurrentFullName, true); Global.AddToLogFile(CurrentFullName, "Deleted Directory", "Success"); Global.Attention.AddContent(MyFunc.Set(2, 1), $"Successfully Deleted Directory {CurrentFullName}"); } catch (UnauthorizedAccessException) { Global.Attention.AddContent(MyFunc.Set(2, 1), "Access Denied"); Global.AddToLogFile(CurrentFullName, "Trying to Delete Directory", "Access Denied"); } catch (Exception) { Global.Attention.AddContent(MyFunc.Set(2, 1), "Can not Delete Directory"); Global.AddToLogFile(CurrentFullName, "Trying to make Delete Directory", "Can not make Delete Directory"); } return; } }
bool PathTryier(string SomePath001) { try { string[] TryDir = Directory.GetDirectories(SomePath001); } catch (UnauthorizedAccessException) { Global.Attention.AddContent(MyFunc.Set(2, 1), "Access Denied"); Global.AddToLogFile(SomePath001, "Trying to open a directory", "Access Denied"); return(false); } catch (Exception) { Global.Attention.AddContent(MyFunc.Set(2, 1), "Can not open Directory"); Global.AddToLogFile(SomePath001, "Trying to open a directory", "Can not open Directory"); return(false); } return(true); }
public void MakeTree(string SomePath001) { try { string[] TryDir = Directory.GetDirectories(SomePath001); } catch (UnauthorizedAccessException) { //Global.Attention.Show("Access Denied"); Global.Attention.AddContent(MyFunc.Set(2, 1), "Access Denied"); Global.AddToLogFile(SomePath001, "Trying to make Tree", "Access Denied"); return; } catch (Exception) { Global.Attention.AddContent(MyFunc.Set(2, 1), "Can not make Tree"); Global.AddToLogFile(SomePath001, "Trying to make Tree", "Can not make Tree"); return; } ShowDirRec(SomePath001, ""); }