dip s

dip s

  • 1.4k
  • 256
  • 76.6k

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
  1. string FileName ="Image1.jpg";      
  2. string Root = @"" + "IPAddress\\SharedFolderName" + '\\' + CustID;    
  3.     
  4.  if (!Directory.Exists(Root))    
  5.                    {    
  6.                        Directory.CreateDirectory(Root);    
  7.                    }    
  8.     
  9. string filePath = Root + "\\" + FileName;    
  10.     
  11. File.WriteAllBytes(filePath, Convert.FromBase64String(image));    
  12. \\ 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.
 
 

Answers (2)