资源简介

请参考:http://blog.csdn.net/dwj901125/article/details/23701063 这里有相当详尽的实现过程。

资源截图

代码片段和文件信息

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Services;
using System.IO;
using System.Security.Cryptography;
namespace StateGrid95598
{
    /// 
    /// WebService1 的摘要说明
    /// 

    [WebService(Namespace = “http://tempuri.org/“)]
    [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
    [System.ComponentModel.ToolboxItem(false)]
    // 若要允许使用 ASP.NET AJAX 从脚本中调用此 Web 服务,请取消注释以下行。 
    // [System.Web.script.Services.scriptService]
    public class WebService1 : System.Web.Services.WebService
    {

        [WebMethod]
        public string HelloWorld()
        {
            return “Hello World“;
        }

        [WebMethod]
        public bool CreateFile(string fileName)
        {
            bool isCreate = true;
            try
            {
                //首先设置上传服务器文件的路径  然后发布web服务 发布的时候要自己建一个自己知道的文件夹 
                fileName = Path.Combine(@“f:\ceshi\“ + Path.GetFileName(fileName));
                FileStream fs = new FileStream(fileName FileMode.Create FileAccess.ReadWrite FileShare.ReadWrite);
                fs.Close();
            }
            catch
            {
                isCreate = false;
            }
            return isCreate;
        }
        [WebMethod]
        public bool Append(string fileName byte[] buffer)
        {
            bool isAppend = true;
            try
            {
                fileName = Path.Combine(@“d:\“ + Path.GetFileName(fileName));
                FileStream fs = new FileStream(fileName FileMode.Open FileAccess.ReadWrite FileShare.ReadWrite);
                fs.Seek(0 SeekOrigin.End);
                fs.Write(buffer 0 buffer.Length);
                fs.Close();
            }
            catch
            {
                isAppend = false;
            }
            return isAppend;
        }
        [WebMethod]
        public bool Verify(string fileName string md5)
        {
            bool isVerify = true;
            try
            {

                fileName = Path.Combine(@“d:\“ + Path.GetFileName(fileName));
                FileStream fs = new FileStream(fileName FileMode.Open FileAccess.ReadWrite FileShare.ReadWrite);
                MD5CryptoServiceProvider p = new MD5CryptoServiceProvider();
                byte[] md5buffer = p.ComputeHash(fs);
                fs.Close();
                string md5Str = ““;
                List strList = new List();
                for (int i = 0; i < md5buffer.Length; i++)
                {
                    md5Str += md5buffer[i].ToString(“x2“);
                }
                if (md5 != md5Str)
                    isVerify = false;
            }
            catch
            {
                isVerify = false;
            }
            return isVerify;
        }
    }
}

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----
     目录           0  2014-04-14 20:17  WebServiceTest\
     目录           0  2014-04-08 15:55  WebServiceTest\Backup\
     目录           0  2014-04-08 15:55  WebServiceTest\Backup\StateGrid95598\
     文件        2614  2014-04-08 11:06  WebServiceTest\Backup\StateGrid95598.sln
     文件       36352  2014-04-07 23:45  WebServiceTest\Backup\StateGrid95598.suo
     目录           0  2014-04-08 15:55  WebServiceTest\Backup\StateGrid95598\Properties\
     文件        1329  2014-04-05 22:40  WebServiceTest\Backup\StateGrid95598\Properties\AssemblyInfo.cs
     文件        4171  2014-04-08 11:09  WebServiceTest\Backup\StateGrid95598\StateGrid95598.csproj
     文件        1086  2014-04-06 00:48  WebServiceTest\Backup\StateGrid95598\StateGrid95598.csproj.user
     文件         313  2014-04-05 22:40  WebServiceTest\Backup\StateGrid95598\Web.config
     文件        1240  2014-04-05 22:40  WebServiceTest\Backup\StateGrid95598\Web.Debug.config
     文件        1301  2014-04-05 22:40  WebServiceTest\Backup\StateGrid95598\Web.Release.config
     文件         104  2014-04-05 22:43  WebServiceTest\Backup\StateGrid95598\WebService1.asmx
     文件        3074  2014-04-07 23:35  WebServiceTest\Backup\StateGrid95598\WebService1.asmx.cs
     目录           0  2014-04-08 15:55  WebServiceTest\Backup\WindowsFormsApplication1\
     文件         617  2014-04-07 23:08  WebServiceTest\Backup\WindowsFormsApplication1\app.config
     文件        2477  2014-04-07 23:21  WebServiceTest\Backup\WindowsFormsApplication1\Form1.cs
     文件        2035  2014-04-05 22:50  WebServiceTest\Backup\WindowsFormsApplication1\Form1.Designer.cs
     文件        5817  2014-04-05 22:50  WebServiceTest\Backup\WindowsFormsApplication1\Form1.resx
     文件         505  2014-04-05 22:48  WebServiceTest\Backup\WindowsFormsApplication1\Program.cs
     目录           0  2014-04-08 15:55  WebServiceTest\Backup\WindowsFormsApplication1\Properties\
     文件        1380  2014-04-05 22:48  WebServiceTest\Backup\WindowsFormsApplication1\Properties\AssemblyInfo.cs
     文件        2896  2014-04-05 22:48  WebServiceTest\Backup\WindowsFormsApplication1\Properties\Resources.Designer.cs
     文件        5612  2014-04-05 22:48  WebServiceTest\Backup\WindowsFormsApplication1\Properties\Resources.resx
     文件        1124  2014-04-07 23:08  WebServiceTest\Backup\WindowsFormsApplication1\Properties\Settings.Designer.cs
     文件         200  2014-04-07 23:08  WebServiceTest\Backup\WindowsFormsApplication1\Properties\Settings.settings
     目录           0  2014-04-08 15:55  WebServiceTest\Backup\WindowsFormsApplication1\Service References\
     目录           0  2014-04-08 15:55  WebServiceTest\Backup\WindowsFormsApplication1\Service References\ServiceReference1\
     文件        1418  2014-04-07 23:08  WebServiceTest\Backup\WindowsFormsApplication1\Service References\ServiceReference1\configuration.svcinfo
     文件       19738  2014-04-07 23:08  WebServiceTest\Backup\WindowsFormsApplication1\Service References\ServiceReference1\configuration91.svcinfo
     文件       19987  2014-04-07 23:08  WebServiceTest\Backup\WindowsFormsApplication1\Service References\ServiceReference1\Reference.cs
............此处省略105个文件信息

评论

共有 条评论