草庐IT

corrected_path

全部标签

c# - Process.Start() 和 PATH 环境变量

我有以下简单的C#应用程序,它只是尝试启动“jconsole.exe”,它在我的机器上位于C:\Programs\jdk16\bin中。usingSystem;usingSystem.Diagnostics;namespacednet{publicclassdnet{staticvoidMain(string[]args){try{Process.Start("jconsole.exe");Console.WriteLine("Success!");}catch(Exceptione){Console.WriteLine("{0}Exceptioncaught.",e);}}}}如果我

c# - new FileInfo(path).Name 与 Path.GetFileName(path)

哪个更好用,为什么?我的意思是这两个命令在哪些方面不同以及如何不同?性能、可读性……newFileInfo(path).Name或Path.GetFileName(path) 最佳答案 因为您不必为使用Path.GetFilename()创建新对象,所以性能会更好。这是两者的比较:代码:Path.GetFileName("G:\\u.png")IL:IL_0000:ldstr"G:\u.png"IL_0005:callSystem.IO.Path.GetFileName代码:newFileInfo("G:\\u.png").Name

c# - ASP.NET Core 2.0 预览版 1 : How to set up Cookie Authentication with custom login path

在ASP.NETCore2.0中,.UseAuthentication()中间件有一个重大更改,不再允许oldsyntaxmentionedhere去工作。新版本似乎在addAuthentication中处理配置,但我无法在任何地方找到任何关于如何更改指定自定义登录和注销url的旧代码的详细信息。services.AddAuthentication(o=>{//WherecanIspecifythis?????varopt=newCookieAuthenticationOptions(){LoginPath="/api/login",LogoutPath="/api/logout",}

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# - 具有驱动器号的 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#、Excel + csv : how to get the correct encoding?

我已经尝试了很长一段时间,但无法弄清楚。我正在尝试通过*.csv文件将数据导出到Excel。到目前为止效果很好,但是在Excel中打开文件时我遇到了一些编码问题。(左边是原始字符串,右边是EXCEL结果):Messwert(µm/m)==>Messwert(µm/m)DümmeMässöng==>DümmeMässöngNotepad++告诉我文件编码为“ANSIasUTF8”(WTF?)因此,这里是我尝试获得有效结果的不同方法:明显的实现:tWriter.Write(";Messwert(µm/m)");更复杂的(可能尝试了十几种或更多的编码组合:)tWriter.Write

c# - 在 Directory.GetFiles 中使用通配符时出现 "Illegal characters in path"错误

我有一个包含多个包含.doc文件的子目录的目录。示例:C:\Users\user\Documents\testenviroment\Released\test0.docC:\Users\user\Documents\testenviroment\Debug\test1.docC:\Users\user\Documents1\testenviroment\Debug\test2.docC:\Users\user\Documents1\testenviroment\Released\test20.doc我想获取所有Debug文件夹下的所有test*.doc文件。我试过:string[]fi

c# - 线程同步。 lock 究竟是如何访问内存 'correct' 的?

首先,我知道lock{}是Monitor类的合成糖。(哦,句法糖)我正在处理简单的多线程问题,发现不能完全理解锁定内存的任意字如何保护整个其他内存不被缓存是寄存器/CPU缓存等。使用代码示例来解释我在说什么更容易关于:for(inti=0;i最后ms_Sum将包含100000000,这当然是预期的。现在我们准备在2个不同的线程上执行相同的循环,并且上限减半。for(inti=0;i由于没有同步,我们得到不正确的结果-在我的4核机器上它是随机数接近52388219这略大于100000000的一半.如果我们将ms_Sum+=1;包含在lock{}中,我们当然会得到绝对正确的结果100000

c# - asp.net 中 ./, ../, ../../, ~/on file path(URL) 之间的区别

我有一个脚本文件。看到路径是~/Script。但是,如果我输入../../而不是~/,该过程也同样有效。我的网站URL如:https://sample.com/Scripts/angular.js如果我在Scripts之前输入../../,那么它会自动更改以前的URL(https://sample.com/Scripts/angular.js).Whatistheurlprocess?Andhowcanitsautomaticallychanged?andpleasetellabouttheDifferentbetween./,../,../../,~/,/Scripts,Script