English 中文(简体)
是否有更正确的类型,可以将档案途径和档案名称传至一种方法
原标题:Is there a more correct type for passing in the file path and file name to a method

我在这个问题上指的是,如果你需要储存或通过周围的URL,则使用一种扼杀手段可能是一种坏的做法,更好的办法是使用一种URI。 然而,使复杂情况更加复杂和变本加厉。

因此,如果我写到磁盘上的文件,我是否把它当作一个插手,作为档案名称和档案途径,或者是否有更好的类型能够更好地符合要求?

这部法律似乎很模糊,错误很容易发生? 我还需要做一整条检查,如果它是一个有效的档案名称,如果该插图载有数据和清单。

private void SaveFile(string fileNameAndPath) { //The normal stuff to save the file }

最佳回答

对档案名称处以罚款。 “网络框架”对档案名称使用插图,看来是罚款。

为了验证档案名称,你可以尝试并使用一种定期的表述或检查系统无效特性。 然而,处理无效档案名称的特殊案件可能比较容易,处理在你尝试和创建档案时会出现的例外情形——加上你需要这样做。

问题回答

令人不快的是,如果你看像<条码>FileStream的构造者等,他们就使用地表,便可证明是网中这样做的辅助方式。

页: 1 考虑使用<代码>FileInfo(或DirectoryInfo),但这有些不寻常。

你们可以使用文件信息系统(从系统.IO)将其环绕,但在提及档案时,插图则越来越低。

你们总是能够利用“途径”获得档案名称。

努力是罚款,但你应作出一些努力,确保把档案保存到你预期的目录中。

如果你用卷宗重新工作,则通常会进行扼杀。

如果你与URL公司重新合作,你可以考虑使用System.Uri等类别。

Uri myUri = new Uri(myUrl, UriKind.Absolute);

这将使你能够从事诸如古里等性质的工作。 人质、孤寡道路等。 它还将给你一个阵列(Segments),供卢尔的单独子组使用。

http://msdn.microsoft.com/en-us/library/system.uri.aspx” rel=“nofollow noreferer”>。





相关问题
Anyone feel like passing it forward?

I m the only developer in my company, and am getting along well as an autodidact, but I know I m missing out on the education one gets from working with and having code reviewed by more senior devs. ...

NSArray s, Primitive types and Boxing Oh My!

I m pretty new to the Objective-C world and I have a long history with .net/C# so naturally I m inclined to use my C# wits. Now here s the question: I feel really inclined to create some type of ...

C# Marshal / Pinvoke CBitmap?

I cannot figure out how to marshal a C++ CBitmap to a C# Bitmap or Image class. My import looks like this: [DllImport(@"test.dll", CharSet = CharSet.Unicode)] public static extern IntPtr ...

How to Use Ghostscript DLL to convert PDF to PDF/A

How to user GhostScript DLL to convert PDF to PDF/A. I know I kind of have to call the exported function of gsdll32.dll whose name is gsapi_init_with_args, but how do i pass the right arguments? BTW, ...

Linqy no matchy

Maybe it s something I m doing wrong. I m just learning Linq because I m bored. And so far so good. I made a little program and it basically just outputs all matches (foreach) into a label control. ...

热门标签