public bool DownloadFile(string requestFilename, string WriteToFolderPath) { string WriteToFilePath = ""; try { ILCK_Service clientDownload = new LCK_ServiceClient(ConfigSettings_Static.EndpointAddress); DownloadRequest dlRequest = new DownloadRequest(); RemoteFileInfo remFile = new RemoteFileInfo(); dlRequest.FileName = requestFilename; // request file from server remFile = clientDownload.DownloadFileFromServer(dlRequest); // build local filepath to save to WriteToFilePath = Path.Combine(WriteToFolderPath, requestFilename); using (FileStream fileStream = new FileStream(WriteToFilePath, FileMode.Create, FileAccess.Write)) { remFile.FileByteStream.CopyTo(fileStream); } return(true); } catch (Exception ex) { Log("DownloadFile() [requestedFile=" + requestFilename + "][WriteToFilePath=" + WriteToFilePath + "] - Error msg:" + ex.Message); return(false); } }
public bool UploadFile(string ReadFromFilePath) { try { FileInfo fileInfo = new FileInfo(ReadFromFilePath); ILCK_Service clientUpload = new LCK_ServiceClient(ConfigSettings_Static.EndpointAddress); RemoteFileInfo updateRequest = new RemoteFileInfo(); if (!fileInfo.Exists) { return(false); } using (FileStream stream = new FileStream(ReadFromFilePath, System.IO.FileMode.Open, System.IO.FileAccess.Read)) { updateRequest.FileName = Path.GetFileName(ReadFromFilePath); updateRequest.Length = fileInfo.Length; updateRequest.FileByteStream = stream; clientUpload.UploadFileToServer(updateRequest); } return(true); } catch (Exception ex) { Log("UploadFile() - Error msg:" + ex.Message); return(false); } }
public LCK_WCFcommunication(string endPointName) { Logger._LogEnabled = true; lck = new LCK_ServiceClient(endPointName); }