Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
G

Goaty65109

@Goaty65109
About
Posts
26
Topics
6
Shares
0
Groups
0
Followers
0
Following
0

Posts

Recent Best Controversial

  • C#.net (windows )
    G Goaty65109

    as in... public string a = "apple";????? You would the call it by Namespace.Class.Stringname (correct me if I am wrong), but I am pretty sure that is correct if that is what you are referring to.

    C# csharp tutorial question

  • Embed an EXE in a frame within your program
    G Goaty65109

    Thanks, it makes complete sense, as the guy said below I doubt I'll be able to do what I want here. It would explain why Notepad is the only thing that I can get to function correctly, not a big deal was just wanting to fool around with it haha. Thanks for all your input, Daves.

    C# com hosting tutorial question

  • Embed an EXE in a frame within your program
    G Goaty65109

    Yeah I tried that as well, it works as intended, but you can still move the application around inside and resize and such. Is there a way to cut off the bnorders so it can only be resized via the application I create?

    C# com hosting tutorial question

  • Embed an EXE in a frame within your program
    G Goaty65109

    Hey all. First all let me say I am following this guide here: [^] I simply cannot just change the exe (notepad) to another application, it just doesn't work. What can I do to alter this so something like an emulator can have the same effect? I see in the notes below this project that many users have issues getting this to work with something other than notepad. I am also open to resources/guides much newer than this, just through my research I have found this to be the 'simplest' way of accomplishing what I am after. Thanks for any assistance!

    C# com hosting tutorial question

  • File.Move/create just won't work!
    G Goaty65109

    and the finished product! It needs some cleaning up, but for functionalities sake, I am happy with it. Thanks again.

    foreach (string file in settingsFiles)
    {
    IniFile ini = new IniFile(file);
    string settingNum = ini.IniReadValue("info", "settingNumber");

                if (file.Contains(settingNum))
                {
    
                    if (File.Exists(@"C:\\Nightly\\Institutions\\" + settingNum + "\\\\" + settingNum + email))
                    {
                        MessageBox.Show("The file Exists for: " + settingNum);
    
                        File.Move(@"C:\\Nightly\\Institutions\\" + settingNum + "\\\\" + settingNum + email, @"C:\\Nightly\\Institutions\\" + settingNum + "\\\\Archive\\\\" + Parameters.DateOrTime.fileDate.ToString(Parameters.DateOrTime.formatFileDate) + " - " + settingNum + email);
                    }
                    using (File.Create(@"C:\\Nightly\\Institutions\\" + settingNum + "\\\\" + settingNum + email)) { /\*Just creating a file\*/ }
                }
            }
    

    so a little background on what this does - it checks to see if a file already exists, if it does it will move it to the archive folder in the directory the file is located, and renames it to today's date - email.txt. Then it recreates a blank email to be written to in the future.

    C#

  • File.Move/create just won't work!
    G Goaty65109

    Richard I really appreciate you pointing me in the right direction, I took another look at my logic and you're right, it didn't make sense. It sounded good in my head, but I drew it out on paper to see what I was actually trying to accomplish and it didn't work. So here's what I did, and I am getting the looping result I am after, and I think I can go from here. Take a look. same strings as above, plus this, different for each

    foreach (string file in settingsFiles)
    {
    IniFile ini = new IniFile(file);
    string settingNum = ini.IniReadValue("info", "settingNumber");

                if (file.Contains(settingNum))
                {
                   
                        MessageBox.Show("This is setting number: " + settingNum);
                        continue;
                }
             }
    

    I have a file call setting.ini and in each I have the category [info] and a generic setting called settingNumber. NOW on form load it does a message box that says "This is setting number: 1, then 2, then 3, then 4. Now to just play with it to do a check to see if the email file exists, if it does, move it, then it will create an email file for each direcotory that contains a settings file. Thanks! This is the best way to learn, being pointed in the right direction, by someone who isn't an asshole haha. I haven't really had any experiences myself, but sometimes when I use my good friend google, you see some of the responses people give and they are just straight up buttheads. Thanks again :P

    C#

  • File.Move/create just won't work!
    G Goaty65109

    The loop, I think, has everything to do with the file. How else would I know what email files are in each directory? For each *email.txt file in the directories specified do this { If the file exists in the directory, move it } { If the file does NOT exist, create it } ^ so for each file it sees in the string, it should be doing this. So if I have this structure: (Folder) (Email Exists?) 1 Y 2 Y 3 N 4 N 5 Y the intent is to move the file from folder 1 to folder 1\Archive, then create a new one, same for folder 2, then folder 3 doesn't have one so it just creates it, nothing to backup there. Repeat for 4. then backup the file in folder 5 to folder 5\Archive. Hope that helps with my logic.

    C#

  • File.Move/create just won't work!
    G Goaty65109

    settingsFile is a string of settings files, no way to know how many there will be so that is why it loops. Here is the string.

    string[] settingsFiles = Directory.GetFiles(@"C:\Nightly\Institutions\", "settings.ini", SearchOption.AllDirectories);

    C#

  • File.Move/create just won't work!
    G Goaty65109

    Hello all, got myself a confusing mess here. I am going to provide as much information as possible, just let me know if something doesn't make sense. On load, I have a file check and backup that is executed. The backup, doesn't work at all (the Move) and the create, only creates for the first item in the cluster. Here is the code.

    //This pulls the current selected item in combo box to the string
    string instText = comboInst.GetItemText(comboInst.SelectedItem);

    //Items in the combobox have a leading 4 digit number so this
    //string simply grabs those 4 digits into a string
    string folder = instText.Substring(0, 4);

    //This is the path where each item's settings file is located
    string path = @"C:\Nightly\Institutions\" + folder + "\\";

    //This names each email accordingly
    string email = folder + "Email.txt";

    //This is the source path for the email file if it exists for
    //the backup process
    string sourceFile = @"C:\Nightly\Institutions\" + folder + "\\" + folder + "Email.txt";

    //this is where the backups go to... it's the above path
    //with an archive directory
    string destinationFile = @"C:\Nightly\Institutions\" + folder + @"\Archive\";

    //now I want to backup a file if it exists, if it doesn't create
    //the file...

    foreach (string file in settingsFiles)
    {
    if (File.Exists(path + email))
    {
    File.Move(sourceFile, destinationFile);
    }
    if (!File.Exists(path + email))
    {
    Directory.CreateDirectory(path);
    using (File.Create(path + email)) { /*Just creating a path*/ }
    }

    What happens is, the file does NOT get moved if the file exists, and when it creates the file if a file doesn't exist, it only does it for the first item in the list, not each as you would expect a foreach statement to process. If anyone could offer some insight on the wrongdoings of my ways I would appreciate it. Thanks!

    C#

  • substring from form1 to form2....
    G Goaty65109

    Figured it out, dunno how I mucked it up at first, here's how you do it correctly. my button from form1

    private void buttonSched_Click(object sender, EventArgs e)
    {
    string instText = comboInst.GetItemText(comboInst.SelectedItem);
    string folder = instText.Substring(0, 4);
    Schedule Open = new Schedule(instText);
    Open.Show();
    }

    Calling is in form2:

    public partial class Form2 : Form
    {
    private string start;

        public Form2(string inst)
        {
            InitializeComponent();
            this.start = inst;
        }
    

    private void Schedule_Load(object sender, EventArgs e)
    {

            System.Windows.Forms.MessageBox.Show(start);
    

    }

    Quite simple, I know, but I was thinking too much into something that didn't really need that deep of thought. Thanks for the looks! Hope this helps someone in the future. BTW - you can alter the string after it's been called to the new form. I.E.

    System.Windows.Forms.MessageBox.Show(start.Substring(0, 4));

    This is what I needed the code to do, grab the first 4 characters from the string. Now I can use the string raw, or formatted if I like. Thanks again!

    C# com help tutorial question

  • substring from form1 to form2....
    G Goaty65109

    Hey CP, Getting text from one form to another is no problem. But I am having issues showing data from a ComboBox from form1 to display as text in form 2. Alright let's jump right into my example.

    string instText = comboInst.GetItemText(comboInst.SelectedItem);
    string folder = instText.Substring(0, 4);

    comboInst is a combo box that has a list of items that is pulled from a directory. All items have a leading 4 digits that I use a lot in form1. But I can't get those 4 values for the life of me to show even in a messagebox on form 2. It just shows blank when using methods that pull information from a textBox.Text. I need to be able to use both instText and folder strings in other forms. Anyone got any ideas? The example I used is located on stackOverflow: [^] Thanks!

    C# com help tutorial question

  • Simple helper class for DateTime?
    G Goaty65109

    Sorry Dave, didn't realize you had already prevented that from becoming a problem. I just added another private const string to display hours and minutes how I desired, and it works flawlessly, you sir, are a gentleman and a scholar :) :) :) :)

    C# question

  • Simple helper class for DateTime?
    G Goaty65109

    Worked exactly as intended Dave! Thank you for clearing that up for me. Time was a misleading description IN this case. However, this was also going to serve as my template for the time stamp portion of my next step. How can I make Time (one that actually displays the current system time), dynamic? So if I push a button every 5 seconds, it updates the field I am pointing to to the current time? Gosh not only do I sound like a noob, I am a babbling, confusing... noob. :) Edit: Could I have it return my result into the box (or in my literal case, a log.txt file) and then turn around and reset that value?

    C# question

  • Simple helper class for DateTime?
    G Goaty65109

    LOL I understand the concerns. What I have is a huge list of if statements associated with one of my buttons. They all will return this date in some way. Instead of having a million copies of the same code, I want to reference that class so when I change something within that class, it applies to all instances of the code. The error I am getting is An object reference is require for non-static field, method, or property. Copying the code

    DateTime time = DateTime.Now;
    string formatDate = "MM/dd";

    textBox1.Text = time.ToString(formatDate);

    In each and every if statement seems like it would be a big waste of code and space. I have about 20 buttons or so that would use it, each with 2 if statements attached. I want to just reference that code in a helper class and just have to type something like this:

    textBox1.Text = Parameters.time.ToString(Parameters.formatDate);

    which would return "03/11" in the text box, for today's date. I hope this helps clarify my intentions, thanks.

    C# question

  • Simple helper class for DateTime?
    G Goaty65109

    Hey guys, dunno what I am doing wrong here... seems so simple. Helper Class:

    Class Paramaters
    {
    Public DateTime time = DateTime.Now;
    public string formatDate = "MM/dd";
    }

    The Call:

    private void Form1_Load(object sender, EventArgs e)
    {
    textBox1.Text = Parameters.time.ToString(Parameters.formatDate);
    }

    Can anyone shed some light on what exactly I am doing wrong? Thank you.

    C# question

  • [Resolved] Searching for a file in multiple directories?
    G Goaty65109

    Well I'll be damned. It works! Words cannot express my thanks. I can now move on with the fun, visual side of things and actually get this mess put together. You sir are fantastic. Bookmarked, as well as a couple of your Guides (I'll probably be seeing you again once I wish to make simple SELECT queries to SQL). It's 6:15 here, been trying to tackle this since 9pm yesterday, you saved me so much time and I appreciate it. You have a good day man! and good night. :) :) :) :) :) :)

    C# question algorithms help tutorial

  • [Resolved] Searching for a file in multiple directories?
    G Goaty65109

    Here is my main form:

    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...)

    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();
    
        }
    }
    

    }

    C# question algorithms help tutorial

  • [Resolved] Searching for a file in multiple directories?
    G Goaty65109

    Question that came into my mind whilst I am close to being done rebuilding. Can I change the SearchOption.AllDirectories into something more specific? In case I copy and paste a directory to make a backup of the original settings? Like for instance, only look in folders that BEGIN with "BRD"? Thanks again. SearchOption = "\\BRD*"); <--- just an example of what I mean Edit: Ok it's all built. I am now running into an exception. Apparently, the name IniReadValue does not exist in the current context. But it exists in my ini class. public string IniReadValue(string Section,string Key) { StringBuilder temp = new StringBuilder(255); int i = GetPrivateProfileString(Section,Key,"",temp,255,this.path); return temp.ToString(); }

    C# question algorithms help tutorial

  • [Resolved] Searching for a file in multiple directories?
    G Goaty65109

    You are absolutely amazing, thank you so much. I am still rebuilding, but I will get back with you with my results. Is there any way to give you props on this site? I would like to contribute to whatever the reputation tracker is. Thank you so much!

    C# question algorithms help tutorial

  • [Resolved] Searching for a file in multiple directories?
    G Goaty65109

    So let me make sure I understand this correctly, and please forgive me as I am completely novice and am running through as many training videos as I can all the while trying to dream big with my own personal projects. After I generate that information, I just need to plug this into a button (or form_load as intended): IniFile ini = new IniFile(file); comboBox = ini.IniReadValue("Info", "Name"); and it will simply fill my combo box with my desired settings? I have a feeling I am wrong as this sounds too simple, or maybe I just hit the jackpot on my biggest hurdle. Thank you so much for working with me. :)

    C# question algorithms help tutorial
  • Login

  • Don't have an account? Register

  • Login or register to search.
  • First post
    Last post
0
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups