Congratulations - C# Corner Q4, 2022 MVPs Announced
Why Join
Become a member
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
C# Corner Home
Technologies
Monthly Leaders
ASK A QUESTION
Forum guidelines
dip s
1.9k
251
54.4k
Save file in a shared folder not in network or outside network in C#
Sep 30 2020 7:22 AM
Hi,
We have a cloud based apllication, there is a facility called image upload where user can select an image file from his local drive and save that file to a shared folder which is not in user's network. The code with I have written works for shared folder in network but outside the network it fails.
Currently I am passing path which has IP address of shared folder's computer and shared folder name attached to IP address. I think I need to pass username and password also with IP address.
What I have done is
string
FileName =
"Image1.jpg"
;
string
Root = @
""
+
"IPAddress\\SharedFolderName"
+
'\\'
+ CustID;
if
(!Directory.Exists(Root))
{
Directory.CreateDirectory(Root);
}
string
filePath = Root +
"\\"
+ FileName;
File.WriteAllBytes(filePath, Convert.FromBase64String(image));
\\ Here
"image"
is
file content which I want to save
in
shared folder.
This code is running for shared folder in network. But to access folder in other network I think I have to pass username and password.
How to do that in c#?
Any help would be appreciated. Thank you.
Reply
Answers (
2
)
Argument Null Ecxeption
Download file from s3 bucket and save in a shared folder