コード例 #1
0
 public void View(FileTree fileTree)
 {
     try
     {
         string way = fileTree.Way + ((ListBoxItem)fileTree.ListBox.SelectedItem).Content.ToString();
         byte[] bytes;
         if (local.SelectedItems.Count > server.SelectedItems.Count)
         {
             using (var stream = new FileStream(way, FileMode.Open)) { bytes = new byte[stream.Length]; stream.Read(bytes, 0, (int)stream.Length); stream.Close(); }
         }
         else if (local.SelectedItems.Count < server.SelectedItems.Count)
         {
             bytes = client.GetFileBytes(way);
         }
         else
         {
             return;
         }
         Notepad notepad = new Notepad(bytes)
         {
             Readonly = true
         };
     }
     catch (Exception e)
     {
         MessageBox.Show(e.Message);
     }
 }
コード例 #2
0
 public void Edit(FileTree fileTree)
 {
     try
     {
         string way = fileTree.Way + ((ListBoxItem)fileTree.ListBox.SelectedItem).Content.ToString();
         byte[] bytes;
         if (local.SelectedItems.Count > server.SelectedItems.Count)
         {
             using (var stream = new FileStream(way, FileMode.Open)) { bytes = new byte[stream.Length]; stream.Read(bytes, 0, (int)stream.Length); stream.Close(); }
         }
         else if (local.SelectedItems.Count < server.SelectedItems.Count)
         {
             bytes = client.GetFileBytes(way);
         }
         else
         {
             return;
         }
         Notepad notepad = new Notepad(bytes)
         {
             Readonly = false
         };
         notepad.onSaveSubmit += (string text) =>
         {
             byte[] bytearr = ASCIIEncoding.ASCII.GetBytes(text);
             if (local.SelectedItems.Count > server.SelectedItems.Count)
             {
                 File.WriteAllBytes(way, bytearr);
             }
             else if (local.SelectedItems.Count < server.SelectedItems.Count)
             {
                 client.WriteFile(bytearr, way);
             }
             else
             {
                 return;
             }
         };
     }catch (Exception e)
     {
         MessageBox.Show(e.Message);
     }
 }