Process.Start("Notepad");
先创建一个记事本,然后往里面添加文字,不是写好路径创建,
而是一开始就用 Process.Start("Notepad"); 创建一个记事本(不指定路径的),
往里面添加文字之后再操作保存什么的。
FileStream fs = new FileStream(@"D:\example.txt", FileMode.Create, FileAccess.Write);
StreamWriter sw = new StreamWriter(fs);
sw.BaseStream.Seek(0, SeekOrigin.Begin);
sw.WriteLine("hi");
sw.Close();
不是要这个,不知道我说没说明白
先创建一个记事本,然后往里面添加文字,不是写好路径创建,
而是一开始就用 Process.Start("Notepad"); 创建一个记事本(不指定路径的),
往里面添加文字之后再操作保存什么的。
FileStream fs = new FileStream(@"D:\example.txt", FileMode.Create, FileAccess.Write);
StreamWriter sw = new StreamWriter(fs);
sw.BaseStream.Seek(0, SeekOrigin.Begin);
sw.WriteLine("hi");
sw.Close();
不是要这个,不知道我说没说明白
然后往里面添加任意内容,然后在保存的时候指定路径
2)然后用SetWindowText
Process.Start(string,string)的一个实例
using System;
using System.Diagnostics;
using System.ComponentModel;namespace MyProcessSample
{
/// <summary>
/// Shell for the sample.
/// </summary>
class MyProcess
{
/// <summary>
/// Opens the Internet Explorer application.
/// </summary>
void OpenApplication(string myFavoritesPath)
{
// Start Internet Explorer. Defaults to the home page.
Process.Start("IExplore.exe");
// Display the contents of the favorites folder in the browser.
Process.Start(myFavoritesPath);
}
/// <summary>
/// Opens urls and .html documents using Internet Explorer.
/// </summary>
void OpenWithArguments()
{
// url's are not considered documents. They can only be opened
// by passing them as arguments.
Process.Start("IExplore.exe", "www.northwindtraders.com");
// Start a Web page using a browser associated with .html and .asp files.
Process.Start("IExplore.exe", "C:\\myPath\\myFile.htm");
Process.Start("IExplore.exe", "C:\\myPath\\myFile.asp");
}
/// <summary>
/// Uses the ProcessStartInfo class to start new processes, both in a minimized
/// mode.
/// </summary>
void OpenWithStartInfo()
{
ProcessStartInfo startInfo = new ProcessStartInfo("IExplore.exe");
startInfo.WindowStyle = ProcessWindowStyle.Minimized;
Process.Start(startInfo);
startInfo.Arguments = "www.northwindtraders.com";
Process.Start(startInfo);
} static void Main()
{
// Get the path that stores favorite links.
string myFavoritesPath =
Environment.GetFolderPath(Environment.SpecialFolder.Favorites);
MyProcess myProcess = new MyProcess();
myProcess.OpenApplication(myFavoritesPath);
myProcess.OpenWithArguments();
myProcess.OpenWithStartInfo(); }
}
}