我找了一下,好像关键字还不好找,麻烦告诉一下,谢谢!
解决方案 »
- WPF 客户端文件如何上传到服务器指定文件夹中?急!!!
- appsetting双面映射
- 在线急等!(webform)水晶报表中插入‘园饼图表’可以设置标题字体大小,标签字体大小,怎样设置 -----------标注字体
- 求助
- 关于嵌套类(nested class)的访问限定符protected internal和protected?
- 姐姐哥哥妹妹弟弟帮忙 不同网站共享Session问题
- 求助!如何象另一个窗体发送字符串
- 求助:我用mshtml中的dhtmledit控件来编写网页编辑程序,但是无论是浏览或是编辑状态,jpg图片总是不能显示,请高手指教!
- 欢迎班兄归来!散分1000(
- 问下子,XPATH ,怎样模糊查询元素名
- 怎么对access数据库进行操作
- 求救,在线等待!You will be unable to run ASP.Net Web Application or Services.
using System.Diagnostics;
using System.ComponentModel;namespace MyProcessSample
{
/// <summary>
/// Shell for the sample.
/// </summary>
public class MyProcess
{
/// <summary>
/// Opens the Internet Explorer application.
/// </summary>
public 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>
public 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>
public void OpenWithStartInfo()
{
ProcessStartInfo startInfo = new ProcessStartInfo("IExplore.exe");
startInfo.WindowStyle = ProcessWindowStyle.Minimized;
Process.Start(startInfo);
startInfo.Arguments = "www.northwindtraders.com";
Process.Start(startInfo);
} public 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(); }
}
}
Imports System
Imports System.Diagnostics
Imports System.ComponentModel
Namespace MyProcessSample
_
'/ <summary>
'/ Shell for the sample.
'/ </summary>
Public Class MyProcess
' These are the Win32 error code for file not found or access denied.
Private ERROR_FILE_NOT_FOUND As Integer = 2
Private ERROR_ACCESS_DENIED As Integer = 5
'/ <summary>
'/ Prints a file with a .doc extension.
'/ </summary>
Public Sub PrintDoc()
Dim myProcess As New Process()
Try
' Get the path that stores user documents.
Dim myDocumentsPath As String = Environment.GetFolderPath(Environment.SpecialFolder.Personal)
myProcess.StartInfo.FileName = myDocumentsPath + "\MyFile.doc"
myProcess.StartInfo.Verb = "Print"
myProcess.StartInfo.CreateNoWindow = True
myProcess.Start()
Catch e As Win32Exception
If e.NativeErrorCode = ERROR_FILE_NOT_FOUND Then
Console.WriteLine((e.Message + ". Check the path."))
Else
If e.NativeErrorCode = ERROR_ACCESS_DENIED Then
' Note that if your word processor might generate exceptions
' such as this, which are handled first.
Console.WriteLine((e.Message + ". You do not have permission to print this file."))
End If
End If
End Try
End Sub 'PrintDoc
Public Shared Sub Main()
Dim myProcess As New MyProcess()
myProcess.PrintDoc()
End Sub 'Main
End Class 'MyProcess
End Namespace 'MyProcessSample[C#]
using System;
using System.Diagnostics;
using System.ComponentModel;namespace MyProcessSample
{
/// <summary>
/// Shell for the sample.
/// </summary>
public class MyProcess
{
// These are the Win32 error code for file not found or access denied.
const int ERROR_FILE_NOT_FOUND =2;
const int ERROR_ACCESS_DENIED = 5; /// <summary>
/// Prints a file with a .doc extension.
/// </summary>
public void PrintDoc()
{
Process myProcess = new Process();
try
{
// Get the path that stores user documents.
string myDocumentsPath =
Environment.GetFolderPath(Environment.SpecialFolder.Personal); myProcess.StartInfo.FileName = myDocumentsPath + "\\MyFile.doc";
myProcess.StartInfo.Verb = "Print";
myProcess.StartInfo.CreateNoWindow = true;
myProcess.Start();
}
catch (Win32Exception e)
{
if(e.NativeErrorCode == ERROR_FILE_NOT_FOUND)
{
Console.WriteLine(e.Message + ". Check the path.");
} else if (e.NativeErrorCode == ERROR_ACCESS_DENIED)
{
// Note that if your word processor might generate exceptions
// such as this, which are handled first.
Console.WriteLine(e.Message +
". You do not have permission to print this file.");
}
}
}
public static void Main()
{
MyProcess myProcess = new MyProcess();
myProcess.PrintDoc();
}
}
}
见下,具体参数可以自已设一下.ProcessStartInfo startInfo = new ProcessStartInfo("notepad.exe");
startInfo.WindowStyle = ProcessWindowStyle.Minimized;Process.Start(startInfo);startInfo.Arguments = "www.northwindtraders.com";Process.Start(startInfo);
System.Diagnostics.Process.Start("notepad.exe")就能打开记事本了~!