public void DisplaySharedFolder() { List <ManagementBaseObject> sharedList = new List <ManagementBaseObject>(); sharedList = ShareWin.GetSharedFiles(); FolderContainer.Children.Clear(); foreach (var objShare in sharedList) { string name = objShare.Properties["Name"].Value.ToString(); string path = objShare.Properties["Path"].Value.ToString(); List <string> ImageList = new List <string>(); List <string> VideoList = new List <string>(); List <string> AudioList = new List <string>(); List <string> TextList = new List <string>(); ImageList = Seperate.GetImages(path); AudioList = Seperate.GetAudios(path); VideoList = Seperate.GetVideos(path); TextList = Seperate.GetDocs(path); var size = DirSize(new DirectoryInfo(@path)); FolderTile f = new FolderTile(name, path, VideoList.Count.ToString(), AudioList.Count.ToString(), TextList.Count.ToString(), ImageList.Count.ToString(), size); f.DownloadThis.Visibility = Visibility.Hidden; f.ShareCancel.Visibility = Visibility.Visible; f.ShareCancel.Click += (sender1, ex) => this.RemoveShare(f.FolderName.Text); FolderContainer.Children.Add(f); } }
public void RemoveShare(string shareName) { int val = ShareWin.RemoveSharedFolder(shareName); if (val == 0) { Console.WriteLine("Unable to unshare directory."); System.Windows.Forms.MessageBox.Show("Unable to unshare directory."); } else { Console.WriteLine("Folder successfuly unshared."); System.Windows.Forms.MessageBox.Show("Folder successfuly unshared."); } DisplaySharedFolder(); }
private void openBrowser_Click(object sender, RoutedEventArgs e) { var dlg1 = new Ionic.Utils.FolderBrowserDialogEx(); dlg1.Description = "Select a file or folder"; dlg1.ShowNewFolderButton = true; dlg1.ShowEditBox = true; dlg1.ShowBothFilesAndFolders = true; dlg1.ShowFullPathInEditBox = true; dlg1.RootFolder = System.Environment.SpecialFolder.MyComputer; // Show the FolderBrowserDialog. DialogResult result = dlg1.ShowDialog(); if (result == DialogResult.OK) { var path = dlg1.SelectedPath; //System.Windows.Forms.MessageBox.Show(path); var match = Regex.Match(path, @".*\\(.*)$"); var name = match.Groups[1].Value; var myPath = "\\\\" + Environment.MachineName + "\\" + name; int accessType = 0; if (Directory.Exists(dlg1.SelectedPath)) { var check = ShareWin.CreateSharedFolder(path, name, name, accessType); switch (check) { case 0: Console.WriteLine("Folder successfuly shared."); AppendNewShare(name, path); break; case 1: Console.WriteLine("Exception Thrown"); break; case 2: Console.WriteLine("Access Denied"); break; case 8: Console.WriteLine("Unknown Failure"); break; case 9: Console.WriteLine("Invalid Name"); break; case 10: Console.WriteLine("Invalid Level"); break; case 21: Console.WriteLine("Invalid Parameter"); break; case 22: Console.WriteLine("Duplicate Share"); break; case 23: Console.WriteLine("Redirected Path"); break; case 24: Console.WriteLine("Unknown Device or Directory"); break; case 25: Console.WriteLine("Net Name Not Found"); break; default: Console.WriteLine("Folder cannot be shared."); break; } } else { System.Windows.Forms.MessageBox.Show("Not allowed in Windows Environment"); } } }