C# 文件块执行的维度

C# 文件块执行的维度,c#,visual-studio-2010,C#,Visual Studio 2010,我有这个代码用于下载后启动应用程序 client.DownloadFileAsync(new Uri("http://mysite/myapplication.exe"), tempPath + "\\" + sDownloadFileName); try { string tempPath = System.IO.Path.GetTempPath();

我有这个代码用于下载后启动应用程序

client.DownloadFileAsync(new Uri("http://mysite/myapplication.exe"),   tempPath + "\\" + sDownloadFileName);

                    try
                    {
                    string tempPath = System.IO.Path.GetTempPath();
                    Process.Start(tempPath + "myapplication.exe");                   
                    Application.Exit();
                    }
                    catch
                    {
                    MessageBox.Show"Error, the file is corrupt");
                    }
但是如果文件(http://mysite/myapplication.exe )它不存在。。 创建的文件具有相同的1KB开始和返回错误=( 如果执行文件小于10 MB,是否可以阻止执行文件

                    try
                    {
                    string tempPath = System.IO.Path.GetTempPath();                        
                    if (tempPath + "myapplication.exe" == -10 MB)
                    {
                    MessageBox.Show"Error, the file is corrupt");
                    }
                    else if
                    {
                    Process.Start(tempPath + "myapplication.exe");    
                    }
                    }

下载后使用
FileInfo
检查大小

try
{
    string tempPath = System.IO.Path.GetTempPath(); 
    FileInfo fileInfo = new FileInfo(downloadFilePath);
    if (fileInfo.Length < 10*1000*1000)
    {
        MessageBox.Show"Error, the file is corrupt");
    }
    else if
    {
        Process.Start(tempPath + "myapplication.exe");    
    }
}
试试看
{
字符串tempPath=System.IO.Path.GetTempPath();
FileInfo FileInfo=newfileinfo(下载文件路径);
如果(fileInfo.Length<10*1000*1000)
{
MessageBox.Show“错误,文件已损坏”);
}
否则如果
{
Process.Start(tempPath+“myapplication.exe”);
}
}