c# - 仅在文件扩展名之前获取一个句点
问题描述
我正在尝试制作一个小程序来从数据库中读取 URL 并将它们附加到 SAP B1 Deliveries。
示例源 URL: http://xxxx/xx/xxx/xxx/xxx/x/xxxx.pdf
代码:
oAttDelv.Lines.SourcePath = Path.GetDirectoryName(row.AttachURL);
oAttDelv.Lines.FileName = Path.GetFileNameWithoutExtension(row.AttachURL);
oAttDelv.Lines.FileExtension = Path.GetExtension(row.AttachURL);
int iErr = oAttDelv.Add();
int AttEntry = 0;
int temp_int = lErrorCode;
string temp_string = sErrorMsg;
oCompany.GetLastError(out temp_int, out temp_string);
temp_string 中显示的错误如图所示。如何解决 pdf 之前的两个句点并只得到一个句点?
错误:
temp_int = -5002
temp_string = "Source file does not exist , 'http:\\*****************\\jspui\\bitstream\\123456789\\2444\\1\\500393..pdf'"
解决方案
尝试这个:
var temp_string = @"Source file does not exist , 'http:\*****************\jspui\bitstream\123456789\2444\1\500393..pdf'";
var file_name = temp_string.Substring(temp_string.LastIndexOf(@"\") + 1).Replace("..", ".");
推荐阅读
- javascript - SAPUI5:向导/分支 - 等待向导步骤的完成事件返回 OData
- python - Django REST framework 使用 AJAX url 指向 api detail url
- nginx - nginx访问二级目录时,响应内容是一样的
- python - Python mypy 无法从联合返回类型推断类型
- eclipse - 如何强制 Eclipse 从空项目资源管理器开始?
- javascript - 在 Javascript 中找不到文件
- python - 从列表生成矩阵而不使用 for 循环
- python-3.x - 批量大小和重量更新
- mysql - SQL查询;定位并禁用
- c# - sql server 返回 long.parse 显示错误