草庐IT

path-parameter

全部标签

c# - "Access to the path ... is denied"(.NET C#)

我一直在将一个小的XML数据文件保存到外部驱动器,没问题。但后来我尝试使用ApplicationData文件夹和其他文件夹,甚至C:\但没有运气。我收到类似“访问路径“C:\”被拒绝”的错误。只是为了确认,文件已创建并使用当前代码正常读取到外部驱动器。我想这与安全和权限有关,但我没有发现任何有用的东西。如果您能在这方面为我指明正确的方向,请提前致谢!stringfipData=@"F:\IL2\SIIYM\SIIYMData.xml";//externaldriveok:-)//stringfipData=Environment.GetFolderPath(Environment.Sp

c# - ASP.NET MVC3 WebGrid 格式 : parameter

我正在尝试在ASP.NETMVC3中使用新的WebGrid以及我想显示一组执行各种操作(编辑、查看、删除)的链接图标的列之一...为此,我有一个基本上输出以下HTML的HtmlHelper扩展:扩展返回MvcHtmlString并且在RazorView中单独使用时它工作正常..例如:@Html.ActionLinkIconForEditAction("客户",2)问题是我需要在传递对象的ID时在WebGrid列中调用此帮助程序(每个操作一次)。我遇到的问题是编译器给我一个错误,说它不能将MvcHtmlString(或“lambda表达式”,取决于我尝试的调用)转换为格式预期的Syste

c# - 具有驱动器号的 Path.Combine() 行为

根据有关Path.Combine方法的官方文档:https://msdn.microsoft.com/en-us/library/fyy7a5kt(v=vs.110).aspxRemarksIfpath1isnotadrivereference(thatis,"C:"or"D:")anddoesnotendwithavalidseparatorcharacterasdefinedinDirectorySeparatorChar,AltDirectorySeparatorChar,orVolumeSeparatorChar,DirectorySeparatorCharisappended

c# - 为什么这个 Path.Combine 不起作用?

这个问题在这里已经有了答案:WhydoesPath.CombinenotproperlyconcatenatefilenamesthatstartwithPath.DirectorySeparatorChar?(16个答案)关闭9年前。我有以下命令:stringreportedContentFolderPath=Path.Combine(contentFolder.FullName.ToString(),@"\ReportedContent\");当我查看调试器时,我可以看到以下内容:contentFolder.FullName="E:\\"不过reportedContentFolde

c# - 最佳实践 : ref parameter or return value?

其实我是做一个列表作为引用参数如下:publicstaticListListMethod(Listresult)我也看到有人这样做:publicstaticvoidListMethod(refListresult)如果我没记错的话,“my”方法也将list作为引用参数,您应该可以像“other”在他的方法中一样使用它。但在我看来,您输入一个参数,对它做一些事情并在方法返回值中返回它似乎更“干净”。支持或反对一种方法或另一种方法的任何好的论据? 最佳答案 可能您不需要使用ref-但是有区别的。通常当我看到人们使用ref作为引用类型参数

c# - 尝试打开 telerik 报告时出现 "Value cannot be null. Parameter name: instance"错误

在我的解决方案中,我有telerik报告,当尝试在VisualStudio2010设计器中打开它们时,我收到此错误:Valuecannotbenull.Parametername:instanceCallStackatSystem.ComponentModel.TypeDescriptor.AddAttributes(Objectinstance,Attribute[]attributes)atMicrosoft.VisualStudio.Design.VSDesignSurface.CreateDesigner(IComponentcomponent,BooleanrootDesig

c# - 我可以将 C# 函数标记为 "this function does not enumerate the IEnumerable parameter"吗?

同一可枚举的多次枚举对我们来说一直是一个性能问题,因此我们尝试在代码中消除这些警告。但是我们有一个通用的扩展函数来抛出空参数异常,它会生成很多这样的警告。它的签名看起来像这样:publicstaticvoidVerifyArgumentIsNotNull(thisTvalue,stringvalueName)whereT:class它所做的只是检查null并抛出一个格式良好且本地化(对于当时正在使用的任何人类语言)的异常。当此函数用于IEnumerable参数时,它会使代码分析警告IEnumerable可能的多次迭代,因为分析器不知道该函数的作用。我想在这个函数上加上一些标签,上面写着

c# - System.Drawing.Graphics.DrawString - "Parameter is not valid"异常

有时,Microsoft的异常消息毫无帮助,令人恼火。我创建了一个漂亮的小MVC方法来呈现文本。方法体如下。当它到达“DrawString”方法时,我得到一个异常抛出说“参数无效”。请注意,据我所知,字体构造正确(我只是使用10pt的Arial),矩形大小为正且看起来有效,画笔为白色SolidBrush,格式标志不影响输出;也就是说,如果我从调用中排除格式标志,我仍然会收到错误消息。DrawString调用就在底部附近。publicActionResultRenderText(stringfontFamily,floatpointSize,stringforeColor,stringb

c# - MVC 网络 API,错误 : Can't bind multiple parameters

传递参数时出错,"Can'tbindmultipleparameters"这是我的代码[HttpPost]publicIHttpActionResultGenerateToken([FromBody]stringuserName,[FromBody]stringpassword){//...}Ajax:$.ajax({cache:false,url:'http://localhost:14980/api/token/GenerateToken',type:'POST',contentType:"application/json;charset=utf-8",data:{userName

c# - 如何解决错误 : Inconsistent accessibility: parameter type for generic c# interface?

将此代码写入我的项目时出现错误Error1Inconsistentaccessibility:fieldtype'System.Collections.Generic.List'islessaccessiblethanfield'Jain_milan.addchild.m_children'Error2Inconsistentaccessibility:parametertype'System.Collections.Generic.List'islessaccessiblethanmethod'Jain_milan.addchild.addchild(System.Collectio