今天要调整一个项目接口,需要将原始的webservice 接口升级为webapi接口,原始接口中有byte[] 二进制数组参数,初看这个任务,简直小菜一碟。不就升级一下接口嘛! 太尴尬了,处理之后模拟测试,失败了。。。。 步入正题: 1、考虑WebApi 接收方便,定义数据格式使用json,但是json内部的二进制对象无法正常获取, var objModel=JsonConvert.DeserializeObject<JObject>(objRequest.ToString()); ...
Console.WriteLine(System.Windows.Forms.Application.StartupPath);//获取启动了应用程序的可执行文件的路径,不包括可执行文件的名称。(Windows From应用程序才有效) //输出结果:C:\GetPathInfo\GetPath\bin\Debug Console.WriteLine(System.Environment.CurrentDirectory);//获取或设置当前工作目录的完全限定路径。 //输出结果:C:\GetPathInfo\GetPath\bin\Debug Console.WriteLine(System.IO.Directory.GetCurrentDirecto...
C#中一般是可以利用WebClient类和WebRequest类获取网页源代码。下面分别说明这两种方法的实现。 WebClient类获取网页源代码 WebClient类 WebClient类位于System.Net命名空间下,WebClient类提供向URI标识的任何本地、Intranet或Internet资源发送数据以及从这些资源接收数据的公共方法。 源代码 ///引用命名空间 using System.IO; using System.Net; using System.Text; PageUrl = "....
// 获取程序的基目录。 System.AppDomain.CurrentDomain.BaseDirectory // 获取模块的完整路径。 System.Diagnostics.Process.GetCurrentProcess().MainModule.FileName // 获取和设置当前目录(该进程从中启动的目录)的完全限定目录。 System.Environment.CurrentDirectory // 获取应用程序的当前工作目录。 System.IO.Directory.GetCurrentDirectory() // 获取和设置包括该应用程序的目录的名称。 System.AppDomain.CurrentDomain...
原文:C#获取CPU和内存使用率获取内存使用率方式1:using System; using System.Runtime.InteropServices;namespace ConsoleApp1 {publicclass Class1{staticvoid Main(string[] args){Console.WriteLine("总内存:" + FormatSize(GetTotalPhys()));Console.WriteLine("已使用:" + FormatSize(GetUsedPhys()));Console.WriteLine("可使用:" + FormatSize(GetAvailPhys()));Console.ReadKey();}#region 获得内存信息API[DllImport(...
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Net; using System.Text.RegularExpressions; using System.IO; using System.Runtime.InteropServices;namespace pandian.cs {publicclass UpdateDateTime{publicstatic DateTime dt = DateTime.Now;publicstaticvoid UpdateTime(){try{Uri uri = new Uri("http://www.beijing-time.org/time15.asp");System.Windows.Forms....
http://www.educity.cn/develop/495493.html 有时需要在JavaScript中获取后台变量的值,来判断JavaScript的执行逻辑,或者需要调用C#后台方法获取数据,我们可以使用<%= %>表达式很容易地实现,<%= %>主要是对表达式进行绑定,并计算表达式的值。 1.JavaScript获取后台变量。在后台声明一个全局变量,并将变量的访问属性设置为protected或public,就可以在页面使用了。 在后台C#代码中声明一个protected或public类型的变量...
//获取当前进程的完整路径,包含文件名(进程名)。string str = this.GetType().Assembly.Location;result: X:\xxx\xxx\xxx.exe (.exe文件所在的目录+.exe文件名)//获取新的 Process 组件并将其与当前活动的进程关联的主模块的完整路径,包含文件名(进程名)。string str = System.Diagnostics.Process.GetCurrentProcess().MainModule.FileName;result: X:\xxx\xxx\xxx.exe (.exe文件所在的目录+.exe文件名)//获取和设置当前目录(即...
C#获取程序集的版本号:string ver = System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString(); C#中如何将记录项目的最后编译时间:在实际的软件开发工作中,我们通常需要记录某个工程的最后编译时间,原来在C++中,我们有个__DATE__,__TIME__,__FILE__,__LINE__这样的异性宏定义可以使用,但是在C#中,不能使用,但是可以用以下语句来获得最后编译时间。System.IO.File.GetLastWriteTime(this.GetTy...
原文:http://www.cnblogs.com/ingstyle/p/4380794.html
/// <summary>/// 远程获取页面数据/// </summary>/// <param name="Url">地址</param>/// <returns></returns>public static string GetHttpData(string Url){//string sException = null;string sRslt = null;WebResponse oWebRps = null;WebRequest oWebRqst = WebRequest.Create(Url);oWebRqst.Timeout = 50000;//try//{oWebRps = oWebRqst.GetResponse();//}//catch (WebException e)//{// sException = e.Message.ToStrin...
C#获取当前路径的方法如下: 1. System.Diagnostics.Process.GetCurrentProcess().MainModule.FileName -获取模块的完整路径。 2. System.Environment.CurrentDirectory -获取和设置当前目录(该进程从中启动的目录)的完全限定目录。 3. System.IO.Directory.GetCurrentDirectory() -获取应用程序的当前工作目录。这个不一定是程序从中启动的目录啊,有可能程序放在C:\www里,这个函数有可能返回C:\Documents and Settings\ZYB\,或...
XmlDocument xDoc = new XmlDocument(); xDoc.LoadXml(System.Web.HttpUtility.UrlDecode(mCuTable.DATASOURCE)); sDataSourceName = xDoc.SelectNodes("datasource/dataset")[0].Attributes["id"].Value; sDatasetType = xDoc.SelectNodes("datasource/dataset")[0].Attributes["type"].Value;View Code原文:http://www.cnblogs.com/zecVip/p/4757929.html
1protectedvoid ExportExcel(System.Data.DataTable dt)2 {3if (dt == null || dt.Rows.Count == 0) return;4 Microsoft.Office.Interop.Excel.Application xlsxApp = new Application();5if (xlsxApp == null) return;6//System.Globalization.CultureInfo CurrentCI = System.Threading.Thread.CurrentThread.CurrentCulture;7//System.Threading.Thread.CurrentThread.CurrentCulture = new System.Globalization.Cu...
有时候,我们用paint重绘用户控件时,起不到作用,这个时候,我们可以通过获取进程,来重绘控件。下面这个实例是重绘边框的颜色为红色,当边框的风格为FixedSingle的时候,来进行重绘操作。 /// <summary> /// 获得当前进程,以便重绘控件 /// </summary> /// <param name="hWnd"></param> /// <returns></returns> [System.Runtime.InteropServices.DllImport("user32.dll")]static extern IntPtr GetWindowDC(IntPtr hWnd);[Syst...