home
System.IO.File.Copy(oldPathFile, newPathFile);
home
System.IO.DirectoryInfo dir = new System.IO.DirectoryInfo(Location);
foreach(System.IO.FileInfo f in dir.GetFiles("*.*"))
{
ListViewItem item = listView1.Items.Add(f.Name);
item.subItems.Add(Convert.ToString(f.Length));
item.subItems.Add(f.Extension);
}
home
TreeNode main = treeview1.Nodes.Add("Folders in: " + Location );
Main.Tag = "";
foreach(System.IO.DirectoryInfo g in dir.GetDirectories())
{
TreeNode MainNext = Main.Nodes.Add(g.FullName);
MainNext.Tag = (g.FullName);
}
home
System.Diagnostics.Process.Start(@"c:\myFile.text");
home
namespace FileHandlingArticleApp
{
class Program
{
static void Main(String[] args)
{
if(File.Exists("myFile.txt"))
{
// Write to File
string content = File.ReadAllText("myFile.txt");
Console.WriteLine("Current content of file");
Console.WriteLine(content);
Console.WriteLine("Please ener new content for the file");
string newContent = Console.ReadLine();
File.WriteAllText("myFile.txt", newContent);
// Read from File
using(StreamWriter sw = new StreamWriter("myFile.txt"))
{
string newContent = Console.ReadLine();
While(newContent != "end")
{
sw.Write(newContent + Environment.NewLine);
newContent = Console.ReadLine();
}
}
} // end of file exist checking
}
}
}
home
<?xml version = "1.0" ?>
<data>
<myObj> ABC </myObj>
<machine>
<name value="xxx">yyy</name>
</machine>
</data>
XmlDocument xDoc = new XmlDocument();
xDoc.Load("c:\\myFolder\\myFile.xml");
myObj.box.SelectedIndex = myObj.box.FindString( xDoc.SelectSingleNode("data/myObj").nnerText);
foreach(XmlNode node in xDoc.SelectNodes("data/machine/name"))
{
foreach(XmlAttribute attribute in node.Attributes)
{
var x = new cComboBox();
x.Text = node.InnerText;
x.Value = attribute.Value;
myCombox.Items.Add(x);
}
}
home
Process proc = null;
string batDir = string.Format(@"c:\myfolder\");
proc = new Process();
proc.StartInfo.WorkingDirectory = batDir;
proc.StartInfo.FileName = "restore.bat";
proc.StartInfo.CreateNoWindow = false;
proc.Start();
proc.WaitForExit();