Hi
I want to save file in Application folder not in D:. How it can be done
var pdf0 = DateTime.Now.ToString("yyyyMMddHHmm") + "_" +secondPart;
var request0 = new RestRequest(@"/" + secondPart, Method.GET);
var client0 = new RestClient(firstPart);
var content = client0.DownloadData(request0);
MemoryStream ms = new MemoryStream(content);
FileStream file = new FileStream(@"D:\" + pdf0 , FileMode.Create, FileAccess.Write);
ms.WriteTo(file);
file.Close();
Thanks
John IwaszPosted Dec 28, 2022, 4:12 PM
That should get you what you need for Console apps.
Puneet KankarPosted Dec 27, 2022, 8:09 PM
Hi Ramco,
Please check below link and make the changes according to your folder.
https://www.c-sharpcorner.com/blogs/upload-and-save-file-to-other-drive-on-place-of-wwwroot-or-application-directory-in-asp-net1
https://www.aspsnippets.com/questions/451294/Save-file-in-Project-Folder-Directory-using-C-and-VBNet-in-Windows-Application/
Pasang TamangPosted Dec 27, 2022, 4:47 PM
Hi Ramco,
And it is based on .NET Framework or .NET Core? Please try with the code example which I have shared in my previous reply.
Regards,
Pasang
Ramco RamcoPosted Dec 27, 2022, 4:44 PM
Hi
Web application using .net c#
Thanks
Pasang TamangPosted Dec 27, 2022, 3:57 PM
Hi Ramco,
You are developing web application or windows application? If you are using .NET Core then there will be bit different code structure. If you can give me idea about this then I can suggest you what exact code you will need.
Regards,
Pasang
Ramco RamcoPosted Dec 27, 2022, 3:52 PM
Hi Pasang
I am using .net c#. What changes i need to do.
Thanks
Pasang TamangPosted Dec 27, 2022, 3:49 PM
Hi Ramco,
If you are using ASP.NET MVC to develop your application then you can use Server.MapPath. Below is the code example.
PDF is the foldername from my application folder root directory.
Regards,
Pasang