I'm trying to make a module that downloads all of the files of an FTP server's directory and saves it as a .zip file to the user's Desktop. For the specific server I'm using, which I can't disclose its URL and credentials due to it being classified information, I'm getting an error saying the first file can't be read due to access denial:
WinSCP.SessionRemoteException: Error transferring file '/site/wwwroot/.dockerignore'.
Can't open file 'D:\.dockerignore'.
System Error. Code: 5.
Access is denied
Copying files from remote side failed.
I'm not sure if it is this particular server that doesn't allow remote connections from unauthorized external sources or if there is some way of circumventing this using WinSCP.
HTML on .aspx page:
<asp:Label ID="Label116" runat="server" Text="Enter FTP Server Host Name (like "ftp.example.com" if "ftp://ftp.example.com/directory/to/download"): "></asp:Label>
<asp:TextBox ID="TextBox13" runat="server" class="text-box2" Width="668px" Height="38px"></asp:TextBox>
<br />
Enter Directory of FTP Host Name (like "directory/to/download" if "ftp://ftp.example.com/directory/to/download"):
<asp:TextBox ID="TextBox58" runat="server" class="text-box2" Width="400px" Height="38px"></asp:TextBox><br />
<asp:Label ID="Label117" runat="server" Text="Enter Username: "></asp:Label>
<asp:TextBox ID="TextBox56" runat="server" class="text-box2" Width="250px" Height="38px"></asp:TextBox>
<br />
<asp:Label ID="Label118" runat="server" Text="Enter Password: "></asp:Label>
<asp:TextBox ID="TextBox57" runat="server" class="text-box2" Width="250px" Height="38px" TextMode="Password"></asp:TextBox>
<asp:Button ID="Button26" runat="server" class="myButton" OnClick="Button26_Click" Text="Download Entire Repository of Files" />
C#:
protected void Button26_Click(object sender, EventArgs e)
{
string path = Environment.GetFolderPath(Environment.SpecialFolder.Desktop);
path = path.Replace(@"\", @"\\");
SessionOptions sessionOptions = new SessionOptions
{
Protocol = Protocol.Ftp,
HostName = TextBox13.Text,
UserName = TextBox56.Text,
Password = TextBox57.Text,
};
using (Session session = new Session())
{
// Connect
session.Open(sessionOptions);
// Download files
session.GetFiles("/" + TextBox58.Text + "/*", path + @"\*").Check();
}
}
If you want to find this actual module I made on my website, you can find it on https://maxstechandmathsite.azurewebsites.net/Random about halfway down. Any help would be appreciated!