草庐IT

out_file

全部标签

c# - 新的 .csproj 格式 - 如何将整个目录指定为子目录的 "linked file"?

有了新的.csproj格式(以及旧格式),可以将文件添加为项目文件夹外部的链接:也可以使用glob模式来包含多个文件:但是如何将两者结合起来呢?我尝试了什么前两个只创建一个链接文件(名称分别为*.cs和*)。第三个简单地出错了。有没有办法将globbing与链接文件结合到目标项目中的特定位置?如果不是,我如何在不知道有多少文件或它们的名称是什么的情况下链接目录中的所有文件? 最佳答案 虽然以前在使用glob扩展时使用%(RecursiveDir)元数据是可能的(Link="Resources\%(RecursiveDir)%(Fil

c# - .Net WebServices 和 out/ref WebMethod 参数

我从我们的供应商之一那里收到了一些他们正在发布的网络服务的文档,他们非常具体地指出,在他们的一个WebMethods上,一个参数有out修饰符(?不确定这是否是正确的描述符)例如考虑以下WebMethod签名:[WebMethod]publicvoidHelloWorld(outstringstrVal){strVal="HelloWorld";}[显然实际方法不是HelloWorld方法]现在,我从未考虑过设计带有out/ref参数的WebMethod,这让我想知道他们为什么会使用它。为了理解这个设计决定的应用,我将一个原型(prototype)和一些基本的HelloWorld风格的

c# - .NET 2.0 : File. AppendAllText(...) - 线程安全实现

作为无聊的好奇心练习,考虑以下简单的日志记录类:internalstaticclassLogging{privatestaticobjectthreadlock;staticLogging(){threadlock=newobject();}internalstaticvoidWriteLog(stringmessage){try{lock(threadlock){File.AppendAllText(@"C:\logfile.log",message);}}catch{...handleloggingerrors...}}}File.AppendAllText(...)周围是否需要锁

c# - 错误 : A project with an out put type of class library

我试图找出.net并得到这段代码,当我尝试从VS2008运行时它给我这个错误AprojectwithanOutputTypeofClassLibrarycannotbestarteddirectly.Inordertodebugthisproject,addanexecutableprojecttothissolutionwhichreferencestothelibraryproject.Settheexecutableprojectasthestartupproject我正在学习C#,所以不知道该做什么 最佳答案 您不能运行库。

c# - 为什么不能将属性作为 out 参数传递?

例如:int?qID=null;answer.QuestionID=int.TryParse(lblID.Text,outqID.Value)?qID:null;//Error:PropertyorIndexermaynotbepassedasanoutotrefparameter.微软文档中说:“作为out参数传递的变量不需要初始化。但是,必须在方法返回之前为out参数赋值。”然后:“属性不是变量,不能作为输出参数传递。那么底层.net平台设计禁止通过out设置对象的属性的原因是什么?out的值也不必是引用对象——使用值类型是完全合法的。那为什么不呢? 最

c# - string.split() "Out of memory exception"读取制表符分隔文件时

我在我的C#代码中使用string.split()来读取制表符分隔的文件。我正面临下面代码示例中提到的“OutOfMemory异常”。这里我想知道为什么文件大小为16MB时会出现问题?这是正确的方法吗?using(StreamReaderreader=newStreamReader(_path)){//...........Loadthefirstlineofthefile................stringheaderLine=reader.ReadLine();MeterDataIPValueListobjMeterDataList=newMeterDataIPValueL

c# - 电子邮件删除附件后,错误 "The process cannot access the file because it is being used by another process."

我正在做一个电子邮件表单。电子邮件有附件,并在附加文件后发送电子邮件。接下来需要从服务器删除文件。当我试图获取文件时,它给了我主题错误。我什至在删除文件之前调用了GC.Collect(),但错误仍然存​​在。我删除文件的代码是:privatevoidDeleteFiles(DataTabledt){GC.Collect();String[]sAttachments=newString[dt.Rows.Count];try{sAttachments=newString[dt.Rows.Count];for(Int32J=0;J要将文件附加到电子邮件,我的代码是:oMess.Subject

c# - 如何从抛出异常的方法中通过 out/ref 参数获取值?

此代码输出“输出值”。classP{publicstaticvoidMain(){stringarg=null;try{Method(outarg);}catch{}Console.WriteLine(arg);}publicstaticvoidMethod(outstringarg){arg="outvalue";thrownewException();}}但是这个没有。classP{publicstaticvoidMain(){object[]args=newobject[1];MethodInfomi=typeof(P).GetMethod("Method");try{mi.In

c# - System.Net.Mail.SmtpException : The operation has timed out. 错误在asp.net发送邮件代码使用godaddy托管

我正在使用以下代码和平使用godaddy托管发送邮件。但它抛出System.Net.Mail.SmtpException:Theoperationhastimedout.protectedvoidsendmail(){varfromAddress="frommailid@site.com";//anyaddresswheretheemailwillbesendingvartoAddress="to@gmail.com";//PasswordofyourgmailaddressconststringfromPassword="mypassword";//Passingthevaluesa

c# - 如何实现异步 File.Delete/Create/Move?

由于我必须在我的应用程序中进行大量文件I/O操作,我决定异步实现它们。查看MSDN,没有File.Create、File.Delete和File.Move的异步副本。据我了解,原因是不存在用于文件删除、创建或移动的异步Win32实现,所以我最终得到以下解决方案:publicstaticTaskDeleteAsync(stringpath){Guard.FileExists(path);returnTask.Run(()=>File.Delete(path));}publicstaticTaskCreateAsync(stringpath){Guard.IsNotNullOrWhites