I need to handle Images with really long paths (no way to save to shorter paths because files already exist in company). For the System.IO.path
I had the same problem and found AlphaFS (can handle long paths way over 260 chars), which works perfectly. Is there any way to do the same thing for the System.drawing.Image
class?
Id need that in general, but as an example I get the PathTooLong-Exception
when calling Image.FromFile(path);
Asked
Active
Viewed 82 times
0

MMMagic
- 182
- 2
- 14
-
1This isn't really a question about `System.Drawing.Image` so much as dealing with long paths in .NET. http://stackoverflow.com/questions/530109/how-to-avoid-system-io-pathtoolongexception – Michael Petito Feb 20 '15 at 13:24
-
well as I wrote, for the Path class I found a solution. I really need one for the `System.drawing.Image` – MMMagic Feb 20 '15 at 13:27
-
If you can get a `Stream` or `byte[]` from AlphaFS using your long path then you can simply use Patrick's example to load the image using `FromStream`. – Michael Petito Feb 20 '15 at 13:31
-
Also if you have a solution to the linked question, I would encourage you to post an answer there. – Michael Petito Feb 20 '15 at 13:34
1 Answers
1
No, there is not. You could load the file yourself, and then read the image from a stream:
using (MemoryStream ms = new MemoryStream(yourOwnReadBytes))
{
Image i = Image.FromStream(ms);
}

Patrick Hofman
- 153,850
- 22
- 249
- 325