imapX 路径中存在非法字符
请注意,我找到了一种对我来说实际上更有效的解决方法。那就是使用字节流并解码而不是根本保存。因此,答案不是必需的,但我仍然对人们的任何评论感兴趣。
路径中存在非法字符问题。我已经尝试过同一事物的许多不同版本,当然这只是我需要的一条路径,而且我相当确定我知道一条路径是什么样的!有人可以建议我可能做错了什么吗?
我正在使用 http://hellowebapps.com/products/imapx/
连接,其他一切都正常!
代码:
foreach (Message m in _imapClient.Folders["Football"].Messages)
{
m.Process();
List<Attachment> attachment = m.Attachments;
foreach (var a in attachment)
{
a.SaveFile(@"C:\FileDrop\hello.csv");
//a.SaveFile(@"C:\FileDrop\");
}
}
堆栈跟踪:
System.ArgumentException:路径中存在非法字符。在 System.IO.Path.CheckInvalidPathChars(字符串路径)位于 System.IO.Path.GetFileName(字符串路径)位于 System.IO.FileStream..ctor(字符串路径、FileMode模式、FileAccess 访问)位于 ImapX.Attachment.SaveFile(String downloadLocation)
PLEASE NOTE, I have found a work around which actually works out better for me. That is to use the byte stream and decode rather than save at all. Therefore answers are non-essential but I would still be interested in any comments people have.
Having trouble with illegal characters in path. I have tried many different versions of the same thing, surely it's just a path I need, and I'm fairly sure I know what one looks like! Can someone suggest what I may be doing wrong?
I am using http://hellowebapps.com/products/imapx/
Connection and everything else is okay!
Code:
foreach (Message m in _imapClient.Folders["Football"].Messages)
{
m.Process();
List<Attachment> attachment = m.Attachments;
foreach (var a in attachment)
{
a.SaveFile(@"C:\FileDrop\hello.csv");
//a.SaveFile(@"C:\FileDrop\");
}
}
Stack Trace:
System.ArgumentException: Illegal characters in path. at
System.IO.Path.CheckInvalidPathChars(String path) at
System.IO.Path.GetFileName(String path) at
System.IO.FileStream..ctor(String path, FileMode mode, FileAccess
access) at ImapX.Attachment.SaveFile(String downloadLocation)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
也许试试这个:
Path.GetFullPath()
Maybe try this:
Path.GetFullPath()
解决这个问题的唯一方法似乎是直接从附件数据中获取字符串 - 使用 Encoding.GetString() 与 Convert.FromBase64String()
然后照常保存文件:MSDN
The only way it seems to get around this is to get the string from the attachment data directly - using Encoding.GetString() with Convert.FromBase64String()
Then just save the file as normal: MSDN