//static void Main(string[] args) //{ // TestShares(); //} static void TestShares() { // Enumerate shares on local computer Console.WriteLine("\nShares on local computer:"); ShareCollection shi = ShareCollection.LocalShares; if (shi != null) { foreach (Share si in shi) { Console.WriteLine("{0}: {1} [{2}]", si.ShareType, si, si.Path); // If this is a file-system share, try to // list the first five subfolders. // NB: If the share is on a removable device, // you could get "Not ready" or "Access denied" // exceptions. if (si.IsFileSystem) { try { DirectoryInfo d = si.Root; DirectoryInfo[] Flds = d.GetDirectories(); for (int i = 0; i < Flds.Length && i < 5; i++) { Console.WriteLine("\t{0} - {1}", i, Flds[i].FullName); } Console.WriteLine(); } catch (Exception ex) { Console.WriteLine("\tError listing {0}:\n\t{1}\n", si, ex.Message); } } } } else { Console.WriteLine("Unable to enumerate the local shares."); } Console.WriteLine(); // Enumerate shares on a remote computer Console.Write("Enter the NetBios name of a server on your network: "); string server = Console.ReadLine(); if (server != null && server.Trim().Length > 0) { Console.WriteLine("\nShares on {0}:", server); shi = ShareCollection.GetShares(server); if (shi != null) { foreach (Share si in shi) { Console.WriteLine("{0}: {1} [{2}]", si.ShareType, si, si.Path); // If this is a file-system share, try to // list the first five subfolders. // NB: If the share is on a removable device, // you could get "Not ready" or "Access denied" // exceptions. // If you don't have permissions to the share, // you will get security exceptions. if (si.IsFileSystem) { try { System.IO.DirectoryInfo d = si.Root; System.IO.DirectoryInfo[] Flds = d.GetDirectories(); for (int i = 0; i < Flds.Length && i < 5; i++) { Console.WriteLine("\t{0} - {1}", i, Flds[i].FullName); } Console.WriteLine(); } catch (Exception ex) { Console.WriteLine("\tError listing {0}:\n\t{1}\n", si.ToString(), ex.Message); } } } } else { Console.WriteLine("Unable to enumerate the shares on {0}.\n" + "Make sure the machine exists, and that you have permission to access it.", server); } Console.WriteLine(); } // Resolve local paths to UNC paths. string fileName = string.Empty; do { Console.Write("Enter the path to a file, or \"Q\" to exit: "); fileName = Console.ReadLine(); if (fileName != null && fileName.Length > 0) { if (fileName.ToUpper() == "Q") { fileName = string.Empty; } else { Console.WriteLine("{0} = {1}", fileName, ShareCollection.PathToUnc(fileName)); } } } while (fileName != null && fileName.Length > 0); }
public bgrCSP(string [] args) { int nshared = 0; // counter for number of shared files if (args.Length == 0) { MessageBox.Show("ovaj program se koristi tako što prevučeš jedan ili\r\nviše fajlova/foldera na ikonicu koju si upravo kliknuo\r\n\r\nza više informacija pogledaj uputstvo", "bgrCopySharePath " + version, MessageBoxButtons.OK, MessageBoxIcon.Asterisk); } else { string all = string.Empty; for (int i = 0; i < args.Length; i++) { string temp = ShareCollection.PathToUnc(args[i]); if (temp.StartsWith("\\")) { all += "[URL]" + temp + "[/URL]\r\n"; nshared++; } } if (all == string.Empty) { MessageBox.Show("fajlovi su iz foldera koji NIJE SHAREOVAN\r\n\r\nshareuj folder pa probaj opet\r\nili stavi fajlove u neki već shareovan folder", "greška", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } else { if (nshared < args.Length) { string srpskaGramatika; int notshared = args.Length - nshared; if (notshared % 10 == 1 && notshared != 11) { srpskaGramatika = "izabran fajl nije shareovan"; } else if ((notshared % 10 == 2 || notshared % 10 == 3 || notshared % 10 == 4) && (notshared != 12 && notshared != 13 && notshared != 14)) { srpskaGramatika = "izabrana fajla nisu shareovana"; } else { srpskaGramatika = "izabranih fajlova nije shareovano"; } MessageBox.Show(notshared + " od " + args.Length + " " + srpskaGramatika + "\r\n\r\npreostalih " + nshared + " su pripremljeni za pasteovanje", "poruka", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); } try { all = "[QUOTE]\r\n" + all + "[/QUOTE]"; //Clipboard.SetText(all); //Clipboard.Clear(); //Clipboard.SetDataObject(all, true, 6, 250); TextBox tb = new TextBox(); tb.Text = all; tb.SelectAll(); tb.Copy(); //MessageBox.Show(tb.Text); SystemSounds.Beep.Play(); } catch (Exception e) { MessageBox.Show("Došlo je do greške. Zapiši ili izvadi screenshot i daj bugeru\r\n\r\n" + e.ToString() + "\r\n" + e.Message, "obavesti bugera", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } } } string message = checkForUpdate(); if (message != "OK") { MessageBox.Show("Došlo je do sledeće greške u pokušaju update-a:\r\n\r\n\"" + message + "\"\r\n\r\nzapamti tekst greške i javi bugeru", "greška", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); } }