/ Published in: C#
This is a small examble on how to move files around in mono and C#.
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
using System; using Gtk; public partial class MainWindow: Gtk.Window { public MainWindow (): base (Gtk.WindowType.Toplevel) { Build (); } protected void OnDeleteEvent (object sender, DeleteEventArgs a) { Application.Quit (); a.RetVal = true; } protected virtual void OnButton1Clicked (object sender, System.EventArgs e) { if(filechooserbutton1.Filename == null) return; if(entry1.Text == null) return; string Src = filechooserbutton1.Filename; string Dest = entry1.Text; if(!fileInfoSrc.Exists) return; if(fileInfoDest.Exists) { if(movebutton.Active) { moveOverwrite(Src,Dest); } else { copyOverwrite(Src,Dest); } } else { if(movebutton.Active) { System.IO.File.Move(Src,Dest); } else { System.IO.File.Copy(Src,Dest); } } } void moveOverwrite(string Src,string Dest) { DialogFlags.NoSeparator, MessageType.Question, ButtonsType.YesNo, "Do you really want to overwrite : " + Dest + " ?"); if((ResponseType)myMessage.Run() == ResponseType.Yes) { myMessage.Destroy(); System.IO.File.Move(Src,Dest); } else {myMessage.Destroy();} } void copyOverwrite(string Src , string Dest) { DialogFlags.NoSeparator, MessageType.Question, ButtonsType.YesNo, "Do you really want to overwrite : " + Dest + " ?"); if((ResponseType)myMessage.Run() == ResponseType.Yes) { myMessage.Destroy(); System.IO.File.Copy(Src,Dest,true); } else {myMessage.Destroy();} } }