Click here to Skip to main content
15,844,155 members
Home / Discussions / C#
   

C#

 
GeneralRe: Searching for a file in multiple directories? Pin
OriginalGriff10-Mar-13 0:23
mveOriginalGriff10-Mar-13 0:23 
GeneralRe: Searching for a file in multiple directories? Pin
Goaty6510910-Mar-13 0:31
Goaty6510910-Mar-13 0:31 
GeneralRe: Searching for a file in multiple directories? Pin
OriginalGriff10-Mar-13 0:42
mveOriginalGriff10-Mar-13 0:42 
GeneralRe: Searching for a file in multiple directories? Pin
Goaty6510910-Mar-13 0:54
Goaty6510910-Mar-13 0:54 
GeneralRe: Searching for a file in multiple directories? Pin
OriginalGriff10-Mar-13 1:00
mveOriginalGriff10-Mar-13 1:00 
GeneralRe: Searching for a file in multiple directories? Pin
Goaty6510910-Mar-13 1:34
Goaty6510910-Mar-13 1:34 
GeneralRe: Searching for a file in multiple directories? Pin
OriginalGriff10-Mar-13 1:55
mveOriginalGriff10-Mar-13 1:55 
GeneralRe: Searching for a file in multiple directories? Pin
Goaty6510910-Mar-13 2:03
Goaty6510910-Mar-13 2:03 
Here is my main form:

C#
using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.IO;
using ReadWriteIni;
using Ini;

namespace ReadWriteIni
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }
        
        private void Form1_Load(object sender, EventArgs e)
        {
            string[] settingsFiles = Directory.GetFiles(@"C:\\Users\\Name\\Desktop\\Projects\\test.Files\\Folders\\",
                    "Settings.txt", SearchOption.AllDirectories);
            comboInst.Items.Clear();
            foreach (string file in settingsFiles)
            {
                IniFile ini = new IniFile(file);
                comboInst.Items.Add(Ini.IniReadValue("Info", "Name"));
            }
        }
    }
}


And here is my Ini Class (Wish there was a spoiler tag to collapse this part...)

C#
using System;
using System.IO;
using System.Runtime.InteropServices;
using System.Text;

namespace Ini
{
    public class IniFile
    {
        public string path;

        [DllImport("kernel32")]
        private static extern long WritePrivateProfileString(string section, string key, string val, string filePath);
        [DllImport("kernel32")]
        private static extern int GetPrivateProfileString(string section, string key, string def, StringBuilder retVal, int size, string filePath);

        public IniFile(string INIPath)
        {
            path = INIPath;
        }
        public void IniWriteValue(string Section, string Key, string Value)
        {
            WritePrivateProfileString(Section, Key, Value, this.path);
        }
        public string IniReadValue(string Section, string Key)
        {
            StringBuilder temp = new StringBuilder(255);
            int i = GetPrivateProfileString(Section, Key, "", temp, 255, this.path);
            return temp.ToString();

        }
    }
}

GeneralRe: Searching for a file in multiple directories? Pin
OriginalGriff10-Mar-13 2:12
mveOriginalGriff10-Mar-13 2:12 
GeneralRe: Searching for a file in multiple directories? Pin
Goaty6510910-Mar-13 2:16
Goaty6510910-Mar-13 2:16 
GeneralRe: Searching for a file in multiple directories? Pin
OriginalGriff10-Mar-13 2:23
mveOriginalGriff10-Mar-13 2:23 
QuestionSuggestions: textbox background and foreground colours. Pin
Septimus Hedgehog9-Mar-13 11:58
Septimus Hedgehog9-Mar-13 11:58 
AnswerRe: Suggestions: textbox background and foreground colours. Pin
Ravi Bhavnani9-Mar-13 14:01
professionalRavi Bhavnani9-Mar-13 14:01 
GeneralRe: Suggestions: textbox background and foreground colours. Pin
Septimus Hedgehog10-Mar-13 0:02
Septimus Hedgehog10-Mar-13 0:02 
QuestionIf statement Pin
Sottyoru9-Mar-13 8:07
Sottyoru9-Mar-13 8:07 
AnswerRe: If statement Pin
PIEBALDconsult9-Mar-13 8:58
mvePIEBALDconsult9-Mar-13 8:58 
AnswerRe: If statement Pin
dusty_dex9-Mar-13 11:29
dusty_dex9-Mar-13 11:29 
GeneralRe: If statement Pin
PIEBALDconsult9-Mar-13 11:57
mvePIEBALDconsult9-Mar-13 11:57 
GeneralRe: If statement Pin
dusty_dex10-Mar-13 7:05
dusty_dex10-Mar-13 7:05 
AnswerRe: If statement Pin
ali_heidari_10-Mar-13 1:10
ali_heidari_10-Mar-13 1:10 
GeneralRe: If statement Pin
jschell10-Mar-13 7:19
jschell10-Mar-13 7:19 
GeneralRe: If statement Pin
ali_heidari_10-Mar-13 7:23
ali_heidari_10-Mar-13 7:23 
QuestionAbout Regex Pin
Sottyoru9-Mar-13 5:50
Sottyoru9-Mar-13 5:50 
AnswerRe: About Regex Pin
PIEBALDconsult9-Mar-13 6:09
mvePIEBALDconsult9-Mar-13 6:09 
GeneralRe: About Regex Pin
Sottyoru9-Mar-13 8:08
Sottyoru9-Mar-13 8:08 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.