public void UploadFile(string targetFilename) { FtpClient c = new FtpClient(Config.FTPServer, Config.FTPServerUser, Config.FTPServerPassw); bool result = c.UploadFile(targetFilename, string.Format("{0}{1}", Config.FTPServerLocation, new FileInfo(targetFilename).Name)); if (!result) throw new ApplicationException("Uploaden niet gelukt"); }
public Mp3File UploadNewFile(string input, DateTime date, string titel, CategoryObj cat) { string filename = string.Format("{0}-{1}.mp3", date.ToString("yyyyMMdd"), titel.Replace(" ", "_").Replace(".", "").ToLowerInvariant()); string targetfilename = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments), filename); EncodeMP3(input, targetfilename); FtpClient c = new FtpClient(FTPServer, FTPServerUser, FTPServerPassw); bool result = c.UploadFile(targetfilename, string.Format("public_html/{0}/{1}", GetFTPServerLocation(cat), filename)); if (!result) throw new ApplicationException("Uploaden niet gelukt"); Mp3File mp3 = new Mp3File(); mp3.naam = filename; mp3.size = new FileInfo(targetfilename).Length; mp3.url = string.Format("{0}{1}/{2}", BaseWebUrl, GetFTPServerLocation(cat), filename); File.Delete(targetfilename); return mp3; }