private void deleteToolStripMenuItem_Click(object sender, EventArgs e) { foreach (ListViewItem item in contentView.SelectedItems) { switch (recognizeSelectedItem(item)) { case 1: //DRIVE break; case 2: //DIRECTORY r.DirectoryInformationResponse.DirectoryInfo dir = (r.DirectoryInformationResponse.DirectoryInfo)item.Tag; if (MessageBox.Show("Are you sure you want to permanently delete this folder", "Delete Folder", MessageBoxButtons.YesNo) == DialogResult.Yes) { FileSystem.RequestDelete(server.serverPort.Stream, dir.FullName); } break; case 3: //FILE r.FileInformationResponse.FileInfo fil = (r.FileInformationResponse.FileInfo)item.Tag; if (MessageBox.Show("Are you sure you want to permanently delete this file", "Delete File", MessageBoxButtons.YesNo) == DialogResult.Yes) { FileSystem.RequestDelete(server.serverPort.Stream, fil.FullName); } break; } } refreshContent(); }
private void renameToolStripMenuItem_Click(object sender, EventArgs e) { ListViewItem sItem = contentView.SelectedItems[0]; //GET THE SELECTED OBJECT switch (recognizeSelectedItem(sItem)) { case 1: //DRIVE break; case 2: //DIRECTORY r.DirectoryInformationResponse.DirectoryInfo dir = (r.DirectoryInformationResponse.DirectoryInfo)sItem.Tag; InputBoxForm di = new InputBoxForm(); di.Response = dir.Name; di.initiateText("Enter the new name of folder", "Rename Folder"); if (di.ShowDialog(this) == DialogResult.OK) { string des = dir.FullName.Substring(0, dir.FullName.Length - dir.Name.Length) + di.Response; if (des != dir.FullName) { FileSystem.RequestRename(server.serverPort.Stream, dir.FullName, des); } } di.Dispose(); break; case 3: //FILE r.FileInformationResponse.FileInfo fil = (r.FileInformationResponse.FileInfo)sItem.Tag; InputBoxForm diF = new InputBoxForm(); diF.Response = fil.Name; diF.initiateText("Enter the new name of file", "Rename File"); if (diF.ShowDialog(this) == DialogResult.OK) { string des = fil.FullName.Substring(0, fil.FullName.Length - fil.Name.Length) + diF.Response; if (des != fil.FullName) { FileSystem.RequestRename(server.serverPort.Stream, fil.FullName, des); } } diF.Dispose(); break; case 0: MessageBox.Show("UnKnown Item found", "Error"); break; } refreshContent(); //REQUEST FOR NEW CONTENTS }
private void PropertiesBoxForm_Load(object sender, EventArgs e) { switch (recognizeSelectedItem(Tag)) { case 1: //DRIVE r.DrivesInformationResponse.DriveInfo div = (r.DrivesInformationResponse.DriveInfo)Tag; Close(); break; case 2: //DIRECTORY r.DirectoryInformationResponse.DirectoryInfo dir = (r.DirectoryInformationResponse.DirectoryInfo)Tag; Text = $"{dir.Name} Properties"; nameLabel.Text = dir.Name; typeLabel.Text = "Folder"; locLabel.Text = dir.FullName.Substring(0, dir.FullName.Length - dir.Name.Length); sizeLabel.Text = "<unknown>"; DateTime dt = FileSystem.StringToDate(dir.CreationTime); createdLabel.Text = $"{dt.DayOfWeek.ToString()}, {MyGlobal.MonthOfYear(dt.Month)} {dt.Day.ToString("00")}, {dt.Year}, {dt.Hour.ToString("00")}:{dt.Minute.ToString("00")}:{dt.Second.ToString("00")}"; dt = FileSystem.StringToDate(dir.LastWriteTime); modifiedLabel.Text = $"{dt.DayOfWeek.ToString()}, {MyGlobal.MonthOfYear(dt.Month)} {dt.Day.ToString("00")}, {dt.Year}, {dt.Hour.ToString("00")}:{dt.Minute.ToString("00")}:{dt.Second.ToString("00")}"; dt = FileSystem.StringToDate(dir.LastAccessTime); accessedLabel.Text = $"{dt.DayOfWeek.ToString()}, {MyGlobal.MonthOfYear(dt.Month)} {dt.Day.ToString("00")}, {dt.Year}, {dt.Hour.ToString("00")}:{dt.Minute.ToString("00")}:{dt.Second.ToString("00")}"; break; case 3: //FILE r.FileInformationResponse.FileInfo fil = (r.FileInformationResponse.FileInfo)Tag; Text = $"{fil.Name.Replace(fil.Extention,"")} Properties"; nameLabel.Text = fil.Name; typeLabel.Text = $"File ({fil.Extention})"; locLabel.Text = fil.FullName.Substring(0, fil.FullName.Length - fil.Name.Length); sizeLabel.Text = $"{fil.Length} bytes"; DateTime dtt = FileSystem.StringToDate(fil.CreationTime); createdLabel.Text = $"{dtt.DayOfWeek.ToString()}, {MyGlobal.MonthOfYear(dtt.Month)} {dtt.Day.ToString("00")}, {dtt.Year}, {dtt.Hour.ToString("00")}:{dtt.Minute.ToString("00")}:{dtt.Second.ToString("00")}"; dtt = FileSystem.StringToDate(fil.LastWriteTime); modifiedLabel.Text = $"{dtt.DayOfWeek.ToString()}, {MyGlobal.MonthOfYear(dtt.Month)} {dtt.Day.ToString("00")}, {dtt.Year}, {dtt.Hour.ToString("00")}:{dtt.Minute.ToString("00")}:{dtt.Second.ToString("00")}"; dtt = FileSystem.StringToDate(fil.LastAccessTime); accessedLabel.Text = $"{dtt.DayOfWeek.ToString()}, {MyGlobal.MonthOfYear(dtt.Month)} {dtt.Day.ToString("00")}, {dtt.Year}, {dtt.Hour.ToString("00")}:{dtt.Minute.ToString("00")}:{dtt.Second.ToString("00")}"; break; } if (objectIcon != null) { pictureBox1.Image = objectIcon; } }
private void openWithNewConnectionToolStripMenuItem_Click(object sender, EventArgs e) { string imm = ""; ListViewItem sItem = contentView.SelectedItems[0]; //GET THE SELECTED OBJECT switch (recognizeSelectedItem(sItem)) { case 1: //DRIVE r.DrivesInformationResponse.DriveInfo div = (r.DrivesInformationResponse.DriveInfo)sItem.Tag; imm = div.RootDirectoryPath; break; case 2: //DIRECTORY r.DirectoryInformationResponse.DirectoryInfo dir = (r.DirectoryInformationResponse.DirectoryInfo)sItem.Tag; imm = dir.FullName; break; case 3: //FILE break; case 0: MessageBox.Show("UnKnown Item found", "Error"); return; } NetworkServer.requestNewConnectionToOpenPort(server.serverPort.ServerIP, new NetworkServer.NewConnectionEstablished( (NetworkServer newServer, CommunicationNetworkStream stream) => { exploreForm f = new exploreForm(); f.server = newServer; f.ImmidiatePath = imm; f.StartPosition = FormStartPosition.CenterScreen; Invoke(new UpdateData(() => { f.Show(); })); } ), new NetworkServer.ErrorEncounted( (RServer newServer, CommunicationNetworkStream stream, string data) => { MessageBox.Show("Server is flooded with connection. Try again later.", "Error"); } ) ); }
private async void openSelectedItem() { ListViewItem sItem = contentView.SelectedItems[0]; //GET THE SELECTED OBJECT switch (recognizeSelectedItem(sItem)) { case 1: //DRIVE r.DrivesInformationResponse.DriveInfo div = (r.DrivesInformationResponse.DriveInfo)sItem.Tag; addressBox.Text = div.RootDirectoryPath; break; case 2: //DIRECTORY r.DirectoryInformationResponse.DirectoryInfo dir = (r.DirectoryInformationResponse.DirectoryInfo)sItem.Tag; addressBox.Text = dir.FullName; break; case 3: //FILE r.FileInformationResponse.FileInfo fil = (r.FileInformationResponse.FileInfo)sItem.Tag; if (fil.Length > 4194304d) { if (MessageBox.Show("Selected file is too long.\nWant to continue...", "Confirm", MessageBoxButtons.YesNo) == DialogResult.No) { return; } } string fPath = await MyGlobal.DB.LocalStorage.GetLocalFile(server.serverPort.ServerIP, fil); if (MyGlobal.DB.LocalStorage.isUpdated) { await MyGlobal.DB.saveDatabase(); } Process.Start(fPath); return; break; case 0: MessageBox.Show("UnKnown Item found", "Error"); break; } refreshContent(); //REQUEST FOR NEW CONTENTS }