private void createSelfExtractingZip(MyFile mf) { try { NetworkDrives.MapDrive("iboxx"); //comment for local testing 3/26 using (Ionic.Zip.ZipFile zip = new Ionic.Zip.ZipFile()) { if (mf.IsFolder) { zip.AddDirectory(mf.From); } else { zip.AddFile(mf.From); } Ionic.Zip.SelfExtractorSaveOptions options = new Ionic.Zip.SelfExtractorSaveOptions(); options.Flavor = Ionic.Zip.SelfExtractorFlavor.ConsoleApplication; zip.SaveSelfExtractor(mf.FullName, options); } NetworkDrives.DisconnectDrive("iboxx"); //comment for local testing } catch (Exception e) { displayError(e); throw; //if (Error == "") { // Error = "Error caught in createSelfExtractingZip() " + e; // throw; //} ////ScriptManager.RegisterStartupScript(this.Page, Page.GetType(), "Message", "<script>alert('Error caught in createSelfExtractingZip() " + e + "');</script>", true); ////this.Response.Write("<script>alert('Error caught in createSelfExtractingZip() " + e + "');</script>"); } }
internal void renameOnWebServer() { NetworkDrives.MapDrive("web"); string currentFolder = this.DestinationCurrentFolder.Substring(this.DestinationHomeFolder.Length + 1); ExpandedFolder = this.DestWebServerFolder + currentFolder + "\\" + FolderName + "\\"; renameFile(); NetworkDrives.DisconnectDrive("web"); }
private void deleteFromWebServer() { string currentFolder = this.DestinationCurrentFolder.Substring(this.DestinationHomeFolder.Length + 1); this.ExpandedFolder = this.DestWebServerFolder + currentFolder + "\\" + FolderName + "\\"; string filePathToDelete = this.ExpandedFolder + OriginalFileName; NetworkDrives.MapDrive("web"); try { File.Delete(filePathToDelete); } catch (Exception e) { this.Response.Write("<script>alert('Unable to renameFile. Reason: " + e + "');</script>"); } NetworkDrives.DisconnectDrive("web"); }
void MapNetworkDrives() { if (NetworkDrives.MapDrive("M", @"\\192.168.21.7\delonfriday", @"rf-dynamics\elia", "elianat4414123") == false) { throw (new SystemException("Cannot map M drive")); } else { } if (NetworkDrives.MapDrive("R", @"\\192.168.21.7\Data", @"rf-dynamics\elia", "elianat4414123") == false) { throw (new SystemException("Cannot map R drive")); } else { } }
private void moveFilesToWebServer() { try { NetworkDrives.MapDrive("web"); foreach (string[] twoPaths in PathsToCopyToWebServer) { string intranetLocation = twoPaths[0]; string webServerLocation = twoPaths[1]; string directoryName = Path.GetDirectoryName(webServerLocation); createDirectoryIfNotExist(directoryName); File.Copy(intranetLocation, webServerLocation, true); } NetworkDrives.DisconnectDrive("web"); this.Successful = true; } catch (Exception e) { displayError(e); throw; //if (Error == "") { // Error = Error = "Error caught in moveFileToWebServer() " + e; // throw; //} } }
public void Sync() { Shares.Clear(); DatabaseConnection connection = DatabaseConnection.Instance; var database = connection.Client.GetDatabase(Properties.Settings.Default.mongodb_database); var sharesCollection = database.GetCollection <BsonDocument>(Properties.Settings.Default.mongodb_collection_shares); using (IAsyncCursor <BsonDocument> cursor = sharesCollection.FindSync(new BsonDocument())) { while (cursor.MoveNext()) { IEnumerable <BsonDocument> batch = cursor.Current; foreach (BsonDocument document in batch) { string shareLetter = document["share_letter"].AsString; string sharePath = document["share_path"].AsString; bool mounted = NetworkDrives.IsDriveMapped(shareLetter); Shares.Add(new NetworkShare(shareLetter, sharePath, mounted)); } } } }