- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
我正在尝试将图像路径上传到数据库并将文件保存在图像文件夹中。除了 getExtension 部分(.jpg、.gif 等...)之外,此方法正常工作,Path.GetExtension 方法始终返回 null (""),我不知道为什么。
您可以在下面找到使用的代码:
string imagesFolderPath = Server.MapPath("//Images");
imagesFolderPath += "//";
string newImageName = addProduct.id.ToString();
string extension = Path.GetExtension(fileUpload.FileName.ToString());
addProduct.imagePath = "Images//" + newImageName + extension;
fileUpload.SaveAs(imagesFolderPath + newImageName);
最佳答案
根据 MSDN Documentation :
The extension of the specified path (including the period "."), or null, or String.Empty. If path is null, GetExtension returns null. If path does not have extension information, GetExtension returns String.Empty.
获得空字符串 ""
的唯一方法是not 的路径为 null
和到不的路径有扩展名。
你得到一个空字符串,因为路径没有扩展名。
关于c# - Path.GetExtension 返回 "",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14054483/
我正在尝试将图像路径上传到数据库并将文件保存在图像文件夹中。除了 getExtension 部分(.jpg、.gif 等...)之外,此方法正常工作,Path.GetExtension 方法始终返回
我正在从 CLI 运行一个 PHP 脚本,该脚本使用 PHP 中的 DirectoryIterator::getExtension() 方法。 我正在运行的 PHP 版本是 5.3.5,但我不断收到错
这个问题在这里已经有了答案: How do I compare strings in Java? (23 个回答) 关闭 7 年前。 我对这种与 FilenameUtils.getExtension
我一直在尝试获取输入的手机号码的分机号。所有其他变量都工作正常。扩展变量返回 Null。看起来它正在向 POST 传递一个空值。 //Initialize the plug
本文整理了Java中org.bouncycastle.cert.X509CRLHolder.getExtensions()方法的一些代码示例,展示了X509CRLHolder.getExtension
本文整理了Java中org.bouncycastle.cert.X509AttributeCertificateHolder.getExtension()方法的一些代码示例,展示了X509Attrib
本文整理了Java中com.zsmartsystems.zigbee.ZigBeeNetworkManager.getExtension()方法的一些代码示例,展示了ZigBeeNetworkMana
关闭。这个问题需要debugging details .它目前不接受答案。 编辑问题以包含 desired behavior, a specific problem or error, and th
更新感谢@IvanL 的评论,事实证明问题是 Google 特有的。从那以后,我尝试了其他提供商,对于那些提供商,一切都按预期进行。 Google 似乎只是不发送 claim 信息。还没有弄清楚为什么
本文整理了Java中org.apache.gobblin.writer.WriterOutputFormat.getExtension()方法的一些代码示例,展示了WriterOutputFormat
我正在更改目录中所有文件的名称,如果它是文本文件,我正在更改内容,但它似乎不起作用,文件名已正确更改,但内容为空白/消失,这是我的代码: import java.io.BufferedReader;
本文整理了Java中com.google.gwt.webgl.client.WebGLRenderingContext.getExtension()方法的一些代码示例,展示了WebGLRenderin
本文整理了Java中com.google.gdata.data.youtube.YouTubeMediaGroup.getExtension()方法的一些代码示例,展示了YouTubeMediaGro
本文整理了Java中com.koolearn.klibrary.core.filesystem.ZLFile.getExtension()方法的一些代码示例,展示了ZLFile.getExtensio
当我添加 ".ToLowerInvariant()" 对于 Path.GetExtension(file.FileName),ReSharper 会针对可能的 Nullreference 异常发出警告
我是一名优秀的程序员,十分优秀!