日韩无码专区无码一级三级片|91人人爱网站中日韩无码电影|厨房大战丰满熟妇|AV高清无码在线免费观看|另类AV日韩少妇熟女|中文日本大黄一级黄色片|色情在线视频免费|亚洲成人特黄a片|黄片wwwav色图欧美|欧亚乱色一区二区三区

RELATEED CONSULTING
相關(guān)咨詢
選擇下列產(chǎn)品馬上在線溝通
服務(wù)時間:8:30-17:00
你可能遇到了下面的問題
關(guān)閉右側(cè)工具欄

新聞中心

這里有您想知道的互聯(lián)網(wǎng)營銷解決方案
C#WebServices升級程序

面介紹一種用C# Web Services升級程序。通過C# Web Services升級程序就象讀寫本機(jī)文件一樣簡單。所以我就直接給出代碼。

興化網(wǎng)站制作公司哪家好,找創(chuàng)新互聯(lián)!從網(wǎng)頁設(shè)計、網(wǎng)站建設(shè)、微信開發(fā)、APP開發(fā)、自適應(yīng)網(wǎng)站建設(shè)等網(wǎng)站項目制作,到程序開發(fā),運營維護(hù)。創(chuàng)新互聯(lián)自2013年創(chuàng)立以來到現(xiàn)在10年的時間,我們擁有了豐富的建站經(jīng)驗和運維經(jīng)驗,來保證我們的工作的順利進(jìn)行。專注于網(wǎng)站建設(shè)就選創(chuàng)新互聯(lián)。

C# Web Services升級程序部分代碼:

 
 
 
  1. using System;
  2. using System.Web;
  3. using System.Web.Services;
  4. using System.Web.Services.Protocols;
  5. using System.IO;
  6. [WebService(Namespace = "http://tempuri.org/")]
  7. [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
  8. public class Service : System.Web.Services.WebService
  9. {
  10. public Service()
  11. {
  12. //如果使用設(shè)計的組件,請取消注釋以下行
  13. //InitializeComponent();
  14. }
  15. /// 
  16. /// 需要升級文件的服務(wù)器路徑
  17. ///  summary>
  18. private const string UpdateServerPath ="d:\\Debug";
  19. [WebMethod(Description = "返回服務(wù)器上程序的版本號")]
  20. public string ServerVer()
  21. {
  22. return "4.0";
  23. }
  24. [WebMethod(Description = "返回需更新的文件")]
  25. public string[] NewFiles()
  26. {
  27. DirectoryInfo di = new DirectoryInfo(UpdateServerPath);
  28. FileInfo[] fi = di.GetFiles();
  29. int intFiles= fi.Length;
  30. string[] myNewFiles = new string[intFiles];
  31. int i = 0;
  32. foreach (FileInfo fiTemp in fi)
  33. {
  34. myNewFiles[i] = fiTemp.Name;
  35. System.Diagnostics.Debug.WriteLine(fiTemp.Name);
  36. i++;
  37. }
  38. return myNewFiles;
  39. }
  40. [WebMethod(Description = "返回需更新的文件的大小")]
  41. public int AllFileSize()
  42. {
  43. int filesize = 0;
  44. string[] files = Directory.GetFiles(UpdateServerPath);
  45. foreach (string file in files)
  46. {
  47. FileInfo myInfo = new FileInfo(file);
  48. filesize += (int)myInfo.Length / 1024;
  49. }
  50. return filesize;
  51. }
  52. [WebMethod(Description = "返回給定文件的字節(jié)數(shù)組")]
  53. public byte[] GetNewFile(string requestFileName)
  54. {
  55. ///得到服務(wù)器端的一個文件
  56. if (requestFileName != null || requestFileName != "")
  57. return getBinaryFile(UpdateServerPath + "\\"+requestFileName);
  58. else
  59. return null;
  60. }
  61. /// 
  62. /// 返回所給文件路徑的字節(jié)數(shù)組。
  63. ///  summary>
  64. ///  name="filename"> param>
  65. ///  returns>
  66. private byte[] getBinaryFile(string filename)
  67. {
  68. if (File.Exists(filename))
  69. {
  70. try
  71. {
  72. //打開現(xiàn)有文件以進(jìn)行讀取。
  73. FileStream s = File.OpenRead(filename);
  74. return ConvertStreamToByteBuffer(s);
  75. }
  76. catch
  77. {
  78. return new byte[0];
  79. }
  80. }
  81. else
  82. {
  83. return new byte[0];
  84. }
  85. }
  86. /// 
  87. /// 把給定的文件流轉(zhuǎn)換為二進(jìn)制字節(jié)數(shù)組。
  88. ///  summary>
  89. ///  name="theStream"> param>
  90. ///  returns>
  91. private byte[] ConvertStreamToByteBuffer(System.IO.Stream theStream)
  92. {
  93. int b1;
  94. System.IO.MemoryStream tempStream = new System.IO.MemoryStream();
  95. while ((b1 = theStream.ReadByte()) != -1)
  96. {
  97. tempStream.WriteByte(((byte)b1));
  98. }
  99. return tempStream.ToArray();
  100. }
  101. }

本文標(biāo)題:C#WebServices升級程序
路徑分享:http://m.5511xx.com/article/djjehci.html