0

how to save file using c# and hosting service inside "images" folder

i already tried code.Paint().Save("c:\image.png", ImageFormat.Png); and suceeded, but only at my local computer, after i uploading to some hosting account ( godaddy ) its not working i already tried @"images\image.png" and ..\images\image.png and ~\images\image.png and the error is A generic error occurred in GDI+.

FileStream fs = new System.IO.FileStream(@"images\image.png", FileMode.Create, FileAccess.ReadWrite);

and still cannot, is that possible to dynamically add file to a hosting? and after I save it, how to open it if I'm using picture box? thanks

Husni Salax
  • 1,968
  • 1
  • 19
  • 29
deni augtaviano
  • 61
  • 1
  • 10
  • i think you have give folder permission in hosting control pannel. – Manish Singh Sep 30 '16 at 11:27
  • i already give full acess, but still can't, as i know, there no C;// path on hosting, so there's my problem – deni augtaviano Sep 30 '16 at 11:34
  • Is it the hosting computer you want to save the file on - or the local computer? – PaulF Sep 30 '16 at 11:37
  • 1
    See this : http://stackoverflow.com/questions/14866603/a-generic-error-occurred-in-gdi-when-attempting-to-use-image-save and http://stackoverflow.com/questions/15862810/a-generic-error-occured-in-gdi-in-bitmap-save-method – PaulF Sep 30 '16 at 11:51

2 Answers2

1

Try code as below,

FileStream fs = new System.IO.FileStream("~/images/image.png", IO.FileMode.OpenOrCreate);


I hope this may solve your problem

Piyush
  • 542
  • 1
  • 8
  • 17
0

according to https://msdn.microsoft.com/en-us/library/system.web.httpserverutility.mappath(v=vs.110).aspx i have successfully saving my file to my hosting HttpContext.Current.Server.MapPath("../images/image.png"),ImageFormat.Png;

deni augtaviano
  • 61
  • 1
  • 10