public void WriteFile(pluginner.File NewFile, int Progress, byte[] Content) { //запись файла _CheckProtocol(NewFile.Path); string InternalURL = NewFile.Path.Replace("file://", ""); try{ Progress = 10; pluginner.File f = NewFile; if (!Directory.Exists(InternalURL)) { File.WriteAllBytes(InternalURL, Content); } Progress = 25; if (!Directory.Exists(InternalURL)) { File.SetAttributes(InternalURL, f.Metadata.Attrubutes); } Progress = 50; File.SetCreationTime(InternalURL, f.Metadata.CreationTimeUTC); Progress = 75; File.SetLastWriteTime(InternalURL, DateTime.Now); Progress = 100; } catch (Exception ex) { //System.Windows.Forms.MessageBox.Show(ex.Message,"LocalFS error",System.Windows.Forms.MessageBoxButtons.OK,System.Windows.Forms.MessageBoxIcon.Stop); new MsgBox(ex.Message, null, MsgBox.MsgBoxType.Error); Console.Write(ex.Message + "\n" + ex.StackTrace + "\n" + "Catched in local fs provider while writing " + InternalURL + "\n"); } }
public pluginner.File GetFile(string url, double Progress) { //чтение файла _CheckProtocol(url); string InternalURL = url.Replace("file://", ""); pluginner.File fsf = new pluginner.File(); //fsf=filesystem file Progress = 50; fsf.Path = "file://" + InternalURL; //this long method have a correction for possibly damages of letters' cases or changes of slashes fsf.Metadata = GetMetadata(url); fsf.Name = new FileInfo(InternalURL).Name; return(fsf); }
/* ЗАМЕТКА РАЗРАБОТЧИКУ * * В данном файле размещаются подпрограммы для управления файлами, которые * вызываются из MainWindow.cs. Также планируется использование этих подпрограмм * после реализации текстовой коммандной строки FC (которая внизу окна). * Все комманды работают с активной и пассивой панелью - Active/PassivePanel. * FC всегда их определяет сам. Пассивая панель - всегда получатель файлов. * Названия комманд - UNIX в верблюжьем регистре (Ls, Rm, MkDir, Touch и т.п.). * Всем коммандам параметры передаются строкой, но допускаются исключения, напр., * если базовая функция "перегружена" функцией для нужд графического интерфейса. * Sorry for my bad english. */ /// <summary> /// Reads the file <paramref name="url"/> and shows in FC Viewer /// </summary> /// <param name="url"></param> public void FCView(string url) { VEd fcv = new VEd(); pluginner.IFSPlugin fs = ActivePanel.FS; if (!fs.FileExists(url)) { //MessageBox.Show(string.Format(locale.GetString("FileNotFound"), ActivePanel.list.SelectedItems[0].Text), "", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); Xwt.MessageDialog.ShowError(string.Format(Locale.GetString("FileNotFound"), ActivePanel.GetValue(ActivePanel.dfDisplayName))); return; } pluginner.File SelectedFile = fs.GetFile(url, new int()); string FileContent = Encoding.ASCII.GetString(fs.GetFileContent(url)); fcv.LoadFile(url, ActivePanel.FS, false); fcv.Show(); }
public pluginner.File GetFile(string url, double Progress) { //чтение файла _CheckProtocol(url); string InternalURL = url.Replace("file://", ""); pluginner.File fsf = new pluginner.File(); //fsf=filesystem file Progress = 50; fsf.Path = "file://" + InternalURL; //this long method have a correction for possibly damages of letters' cases or changes of slashes fsf.Metadata = GetMetadata(url); fsf.Name = new FileInfo(InternalURL).Name; return fsf; }