Created
August 1, 2012 23:36
-
-
Save Demonic722/3231579 to your computer and use it in GitHub Desktop.
Something related to a counter and opening files...
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.IO; | |
using System.Collections.Generic; | |
using System.ComponentModel; | |
using System.Data; | |
using System.Drawing; | |
using System.Linq; | |
using System.Text; | |
using System.Windows.Forms; | |
namespace OpenFileCounter | |
{ | |
public partial class Form1 : Form | |
{ | |
int counter = 0; | |
OpenFileDialog ofd = new OpenFileDialog(); | |
public Form1() | |
{ | |
InitializeComponent(); | |
} | |
private void button1_Click(object sender, EventArgs e) | |
{ | |
if ((ofd.ShowDialog() == DialogResult.OK) && (ofd.OpenFile() != null)) | |
textBox1.Text = Path.GetFileName(ofd.FileName); | |
//for each file opened, add 1 to the counter | |
foreach (string file in ofd.FileNames) | |
{ | |
counter++; | |
label1.Text = counter.ToString(); | |
} | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Imports System.IO | |
Public Class Form1 | |
Dim counter As Integer = 0 | |
Dim ofd As New OpenFileDialog() | |
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click | |
If ofd.ShowDialog() = System.Windows.Forms.DialogResult.OK Then | |
TextBox1.Text = Path.GetFileName(ofd.FileName) | |
End If | |
For Each file As String In ofd.FileNames | |
counter += 1 | |
Label1.Text = counter.ToString() | |
Next | |
End Sub | |
End Class |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment