FTP changes

This commit is contained in:
Jaex 2014-05-30 18:24:43 +03:00
parent 25d5f07f47
commit 739f4243a3
7 changed files with 19 additions and 27 deletions

View file

@ -175,23 +175,23 @@ public enum FTPProtocol
public enum BrowserProtocol public enum BrowserProtocol
{ {
[Description("http://")] [Description("http://")]
Http, http,
[Description("https://")] [Description("https://")]
Https, https,
[Description("ftp://")] [Description("ftp://")]
Ftp, ftp,
[Description("ftps://")] [Description("ftps://")]
Ftps, ftps,
[Description("file://")] [Description("file://")]
File file
} }
public enum ServerProtocol public enum ServerProtocol
{ {
[Description("ftp://")] [Description("ftp://")]
Ftp, ftp,
[Description("ftps://")] [Description("ftps://")]
Ftps ftps
} }
public enum Privacy public enum Privacy

View file

@ -52,13 +52,13 @@ public class FTPAccount : ICloneable
[Category("FTP"), PasswordPropertyText(true)] [Category("FTP"), PasswordPropertyText(true)]
public string Password { get; set; } public string Password { get; set; }
[Category("FTP"), Description("Choose an appropriate protocol to be accessed by the server. This affects the server address."), DefaultValue(ServerProtocol.Ftp)] [Category("FTP"), Description("Choose an appropriate protocol to be accessed by the server. This affects the server address."), DefaultValue(ServerProtocol.ftp)]
public ServerProtocol ServerProtocol { get; set; } public ServerProtocol ServerProtocol { get; set; }
[Category("FTP"), Description("FTP sub folder path, example: Screenshots.\r\nYou can use name parsing: %y = year, %mo = month.")] [Category("FTP"), Description("FTP sub folder path, example: Screenshots.\r\nYou can use name parsing: %y = year, %mo = month.")]
public string SubFolderPath { get; set; } public string SubFolderPath { get; set; }
[Category("FTP"), Description("Choose an appropriate protocol to be accessed by the browser"), DefaultValue(BrowserProtocol.Http)] [Category("FTP"), Description("Choose an appropriate protocol to be accessed by the browser"), DefaultValue(BrowserProtocol.http)]
public BrowserProtocol BrowserProtocol { get; set; } public BrowserProtocol BrowserProtocol { get; set; }
[Category("FTP"), Description("URL = HttpHomePath + SubFolderPath + FileName\r\nIf HttpHomePath is empty then URL = Host + SubFolderPath + FileName\r\n%host = Host")] [Category("FTP"), Description("URL = HttpHomePath + SubFolderPath + FileName\r\nIf HttpHomePath is empty then URL = Host + SubFolderPath + FileName\r\n%host = Host")]
@ -127,9 +127,9 @@ public FTPAccount()
Name = "New account"; Name = "New account";
Host = "host"; Host = "host";
Port = 21; Port = 21;
ServerProtocol = ServerProtocol.Ftp; ServerProtocol = ServerProtocol.ftp;
SubFolderPath = string.Empty; SubFolderPath = string.Empty;
BrowserProtocol = BrowserProtocol.Http; BrowserProtocol = BrowserProtocol.http;
HttpHomePath = string.Empty; HttpHomePath = string.Empty;
HttpHomePathAutoAddSubFolderPath = true; HttpHomePathAutoAddSubFolderPath = true;
HttpHomePathNoExtension = false; HttpHomePathNoExtension = false;

View file

@ -61,7 +61,7 @@ public class LocalhostAccount : ICloneable
[Category("Localhost"), Description("Don't add file extension to URL"), DefaultValue(false)] [Category("Localhost"), Description("Don't add file extension to URL"), DefaultValue(false)]
public bool HttpHomePathNoExtension { get; set; } public bool HttpHomePathNoExtension { get; set; }
[Category("Localhost"), Description("Choose an appropriate protocol to be accessed by the browser. Use 'file' for Shared Folders. RemoteProtocol will always be 'file' if HTTP Home Path is empty. "), DefaultValue(BrowserProtocol.File)] [Category("Localhost"), Description("Choose an appropriate protocol to be accessed by the browser. Use 'file' for Shared Folders. RemoteProtocol will always be 'file' if HTTP Home Path is empty. "), DefaultValue(BrowserProtocol.file)]
public BrowserProtocol RemoteProtocol { get; set; } public BrowserProtocol RemoteProtocol { get; set; }
[Category("Localhost"), Description("file://Host:Port"), Browsable(false)] [Category("Localhost"), Description("file://Host:Port"), Browsable(false)]
@ -107,7 +107,7 @@ public LocalhostAccount()
HttpHomePath = string.Empty; HttpHomePath = string.Empty;
HttpHomePathAutoAddSubFolderPath = true; HttpHomePathAutoAddSubFolderPath = true;
HttpHomePathNoExtension = false; HttpHomePathNoExtension = false;
RemoteProtocol = BrowserProtocol.File; RemoteProtocol = BrowserProtocol.file;
} }
public string GetSubFolderPath() public string GetSubFolderPath()
@ -154,7 +154,7 @@ public string GetUriPath(string filename)
if (string.IsNullOrEmpty(httpHomePath)) if (string.IsNullOrEmpty(httpHomePath))
{ {
RemoteProtocol = BrowserProtocol.File; RemoteProtocol = BrowserProtocol.file;
path = LocalUri.Replace("file://", ""); path = LocalUri.Replace("file://", "");
} }
else else

View file

@ -145,16 +145,7 @@ public bool DirectoryExists(string path)
{ {
if (Connect()) if (Connect())
{ {
try return client.Exists(path);
{
string workingDirectory = client.WorkingDirectory;
client.ChangeDirectory(path);
client.ChangeDirectory(workingDirectory);
return true;
}
catch (SftpPathNotFoundException)
{
}
} }
return false; return false;
@ -171,6 +162,7 @@ public List<string> CreateMultiDirectory(string path)
if (!DirectoryExists(directory)) if (!DirectoryExists(directory))
{ {
CreateDirectory(directory); CreateDirectory(directory);
DebugHelper.WriteLine("FTP directory created: " + path);
directoryList.Add(directory); directoryList.Add(directory);
} }
} }

View file

@ -1715,7 +1715,7 @@ private void InitializeComponent()
this.ucFTPAccounts.Location = new System.Drawing.Point(8, 40); this.ucFTPAccounts.Location = new System.Drawing.Point(8, 40);
this.ucFTPAccounts.Margin = new System.Windows.Forms.Padding(4); this.ucFTPAccounts.Margin = new System.Windows.Forms.Padding(4);
this.ucFTPAccounts.Name = "ucFTPAccounts"; this.ucFTPAccounts.Name = "ucFTPAccounts";
this.ucFTPAccounts.Size = new System.Drawing.Size(792, 516); this.ucFTPAccounts.Size = new System.Drawing.Size(792, 416);
this.ucFTPAccounts.TabIndex = 6; this.ucFTPAccounts.TabIndex = 6;
// //
// tpMega // tpMega

View file

@ -1228,7 +1228,7 @@ private void FTPAccountDuplicateButton_Click(object sender, EventArgs e)
private void FTPAccountTestButton_Click(object sender, EventArgs e) private void FTPAccountTestButton_Click(object sender, EventArgs e)
{ {
TestFTPAccount(Config.FTPAccountList[ucFTPAccounts.lbAccounts.SelectedIndex]); TestFTPAccountAsync(Config.FTPAccountList[ucFTPAccounts.lbAccounts.SelectedIndex]);
} }
private void FtpAccountSettingsGrid_PropertyValueChanged(object s, PropertyValueChangedEventArgs e) private void FtpAccountSettingsGrid_PropertyValueChanged(object s, PropertyValueChangedEventArgs e)

View file

@ -895,7 +895,7 @@ private void FTPOpenClient()
{ {
if (CheckFTPAccounts()) if (CheckFTPAccounts())
{ {
//new FTPClientForm(Config.FTPAccountList[ucFTPAccounts.lbAccounts.SelectedIndex]).Show(); new FTPClientForm(Config.FTPAccountList[ucFTPAccounts.lbAccounts.SelectedIndex]).Show();
} }
} }