Click here to Skip to main content
15,893,588 members
Home / Discussions / C#
   

C#

 
QuestionUpdate listbox items when button is clicked Pin
Mario Lukačić3-Sep-17 2:19
Mario Lukačić3-Sep-17 2:19 
AnswerRe: Update listbox items when button is clicked Pin
Richard MacCutchan3-Sep-17 21:14
mveRichard MacCutchan3-Sep-17 21:14 
GeneralRe: Update listbox items when button is clicked Pin
Mario Lukačić4-Sep-17 2:31
Mario Lukačić4-Sep-17 2:31 
GeneralRe: Update listbox items when button is clicked Pin
Jochen Arndt4-Sep-17 3:49
professionalJochen Arndt4-Sep-17 3:49 
GeneralRe: Update listbox items when button is clicked Pin
Mario Lukačić4-Sep-17 4:01
Mario Lukačić4-Sep-17 4:01 
GeneralRe: Update listbox items when button is clicked Pin
Jochen Arndt4-Sep-17 4:39
professionalJochen Arndt4-Sep-17 4:39 
GeneralRe: Update listbox items when button is clicked Pin
Mario Lukačić4-Sep-17 5:50
Mario Lukačić4-Sep-17 5:50 
GeneralGetting file path and setting to a public variable ?!?! Pin
Mario Lukačić1-Sep-17 8:42
Mario Lukačić1-Sep-17 8:42 
Hi, i have a problem with setting a file path to a public variable.

So, what my code must do :

- open file
- set full path to a file so i can read it in another function
- in other function open ini file for reading

but i cant get a file path to it

Here is a code ;

C#
using System;
using System.Windows.Forms;
using IniParser;
using IniParser.Model;
using System.Collections.Generic;
using System.IO;

namespace WindowsFormsApp1
{
    public partial class Form1 : Form
    {
        public string myFilePath;
        //string myFilePath;

        public Form1()
        {
            InitializeComponent();
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            searchBtn.Enabled = false;
            writeIniBtn.Enabled = false;
            saveBtn.Enabled = false;
        }

        private void openIniBtn_Click(object sender, EventArgs e)
        {
            OpenFileDialog openFile = new OpenFileDialog();

            openFile.InitialDirectory = "c:\\";
            openFile.Filter = "INI files (*.ini)|*.ini";
            openFile.Title = "Select a INI file for edit";

            if (openFile.ShowDialog() == DialogResult.OK)
            {
                string myFilePath = openFile.FileName;
                // MessageBox.Show("my file path : " + myFilePath); // shows full path to file
                
                // enable buttons
                searchBtn.Enabled = true;
                writeIniBtn.Enabled = true;
                saveBtn.Enabled = true;
                openIniBtn.Enabled = false;
            }
        }

        private void listView1_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (listView1.SelectedItems.Count != 0)
            {
                ListViewItem item = listView1.SelectedItems[0];

                string output = item.Text.Split('[', ']')[1];
                string outputt = item.Text.Split('[', ']')[2];
                
                // set name and id
                itemIdTxt.Text = output.ToString();
                nameInput.Text = outputt.ToString();
            }
        }

        private void searchBtn_Click(object sender, EventArgs e)
        {
            MessageBox.Show("my file path : " + myFilePath); // show me a blank message

GeneralRe: Getting file path and setting to a public variable ?!?! Pin
Richard Deeming1-Sep-17 9:30
mveRichard Deeming1-Sep-17 9:30 
GeneralRe: Getting file path and setting to a public variable ?!?! Pin
Mario Lukačić1-Sep-17 9:33
Mario Lukačić1-Sep-17 9:33 
QuestionAPI to https://images.google.com Pin
JanningJuul31-Aug-17 21:34
JanningJuul31-Aug-17 21:34 
AnswerRe: API to https://images.google.com Pin
Richard MacCutchan31-Aug-17 22:06
mveRichard MacCutchan31-Aug-17 22:06 
QuestionIP Address Control in for WPF? Pin
Member 1319657431-Aug-17 20:58
Member 1319657431-Aug-17 20:58 
AnswerRe: IP Address Control in for WPF? Pin
Richard MacCutchan31-Aug-17 21:10
mveRichard MacCutchan31-Aug-17 21:10 
GeneralRe: IP Address Control in for WPF? Pin
Member 1319657431-Aug-17 21:17
Member 1319657431-Aug-17 21:17 
GeneralRe: IP Address Control in for WPF? Pin
Richard MacCutchan31-Aug-17 21:35
mveRichard MacCutchan31-Aug-17 21:35 
AnswerRe: IP Address Control in for WPF? Pin
Bernhard Hiller31-Aug-17 22:24
Bernhard Hiller31-Aug-17 22:24 
SuggestionRe: IP Address Control in for WPF? Pin
Richard Deeming1-Sep-17 2:43
mveRichard Deeming1-Sep-17 2:43 
AnswerRe: IP Address Control in for WPF? Pin
Dave Kreskowiak1-Sep-17 7:52
mveDave Kreskowiak1-Sep-17 7:52 
QuestionWhy It displays error? Pin
sulomila31-Aug-17 20:48
sulomila31-Aug-17 20:48 
AnswerRe: Why It displays error? Pin
Richard MacCutchan31-Aug-17 21:09
mveRichard MacCutchan31-Aug-17 21:09 
GeneralRe: Why It displays error? Pin
sulomila31-Aug-17 21:36
sulomila31-Aug-17 21:36 
GeneralRe: Why It displays error? Pin
Richard MacCutchan31-Aug-17 21:46
mveRichard MacCutchan31-Aug-17 21:46 
GeneralRe: Why It displays error? Pin
sulomila31-Aug-17 22:35
sulomila31-Aug-17 22:35 
GeneralRe: Why It displays error? Pin
Richard MacCutchan31-Aug-17 23:02
mveRichard MacCutchan31-Aug-17 23:02 

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.