- Strength to Increase Rep
- +0
- Strength to Decrease Rep
- -0
- Upvotes Received
- 4
- Posts with Upvotes
- 4
- Upvoting Members
- 3
- Downvotes Received
- 1
- Posts with Downvotes
- 1
- Downvoting Members
- 1
14 Posted Topics
[QUOTE=Ghost;103285]Hi, i'm new 2 C#, so my question may seem stupid... but, what is the code to exit an application. I know in java it is: [CODE]System.exit(0);[/CODE] Thanx in advanced, C++[/QUOTE] [CODE] System.Environment.Exit(0); [/CODE]
Try setting the IsMdiContainer property from the properties box. (Not in your event method) You can set IsMdiContainer to true within the Form1.Designer.cs file or after InitializeComponent() in the forms constructor.
[QUOTE=danuz;1417708]Yes its not a good way of code, but I need to explain to assistent it anyway xD[/QUOTE] Array.Sort() sorts the elements in an entire one-dimensional Array using the IComparable interface implemented by each element of the Array. Straight from MSDN.
All ICollections inherit the Clear method.
[QUOTE=james6754;1416009]Hi all...could anyone please tell me how when working with arrays you could use a forach loop to output the number of a certain item... for instance...if i wanted to find out the number of 5's in an array...could i use a foreach loop to find that out? Thanks[/QUOTE] [CODE]public …
You can identify your teachers home drive with: [CODE]Environment.GetEnvironmentVariable("HomeDrive").[/CODE] For your hard coded location alternative try: [CODE]Environment.GetFolderPath(Environment.SpecialFolders.MyDocuments) + "\\data.txt"[/CODE]
[CODE]public string GrepLineFromFile(string path, string pattern) { if (File.Exists(path)) { foreach (string line in File.ReadAllLines(path)) { if (line.Contains(pattern)) { return (line); } } } else { Console.WriteLine("..file does not exist"); } return (string.Empty); } [/CODE]
A really simple solution. [CODE] private void AppendToFile(string path, string contents) { try { StreamWriter sw = new StreamWriter(new FileStream(path, FileMode.Append, FileAccess.Write)); sw.Write(contents); sw.Close(); } catch (Exception e) { Console.WriteLine(e.Message); } } [/CODE]
[CODE] public void RenameFileOrDirectory(string sourceFileName, string destFileName) { try { if (!sourceFileName.Equals(destFileName)) { FileAttributes attr = File.GetAttributes(sourceFileName); if ((attr & FileAttributes.Directory).Equals(FileAttributes.Directory)) { Directory.Move(sourceFileName, destFileName); } else if ((attr & FileAttributes.ReadOnly).Equals(FileAttributes.ReadOnly)) { Console.WriteLine("..that is read-only"); } else { File.Copy(sourceFileName, destFileName); File.Delete(sourceFileName); } } else { Console.WriteLine("..epic failure"); } } catch (Exception …
[CODE] public void TextFileToList(string path) { List<string> exampleList = new List<string>(); if (File.Exists(path)) { foreach (string line in File.ReadAllLines(path)) { exampleList.Add(line); } } } [/CODE]
You could always create a directory specifically for your application which would house many important files pertinent to the aforementioned application. [CODE] public string storageDirectory; public void InstallStorageDirectory() { // I've found that LocalApplicationData and ApplicationData seem to be interchangeable. this.storageDirectory = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData) + "\\yourStorageDir" if (!IO.Directory.Exists(this.storageDirectory)) { try { …
[QUOTE=vedro-compota;1419434]good evening)) (At us now evening)) Please answer the question - there's a code fragment - [CODE] public string MAP(string FilePath) { FileStream fs; // объявляем байтовый поток try { fs = new FileStream(FilePath, FileMode.Open); } catch (FileNotFoundException exp) { [B][U]return[/U][/B] exp.Message; } catch { [U][B]return[/B][/U] "not possible to open …
[QUOTE=Peter1;1420070]I'm new to c#. [B]How do I add five numbers to each other and indentify the highest and lowest value together with the average value of this five numbers?[/B] Please give me something to begin with (or a whole example of code to study). Have a nice day. Thank you.[/QUOTE] …
The End.
iconoclazt