What's new

Closed Help!!! C Sharp

Status
Not open for further replies.

tamadsijuan

Eternal Poster
Joined
Feb 17, 2016
Posts
849
Reaction
327
Points
268
Get All File Name in Directory

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.IO;

namespace filestry
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}

private void button1_Click(object sender, EventArgs e)
{
string[] fileArray = Directory.GetFiles(@"D:\json");
for (int i = 0; i < fileArray.Length; i++)

{

textBox1.Text = fileArray;

}

}
}
}

isang filename lang nakukuha ko
 
hmmmm.. kasi siguro walang value yung fileArray.Length?
initial value kasi ng i = 0, then start ng iteration, kaso di maka move on kasi hindi naka declare anong value nya?
hula lang..

string[] fileArray = Directory.GetFiles(@"D:\json");
for (int i = 0; i < fileArray.Length; i++) -----> siguro dapat fileArray lang, same as dun sa taas nya
 
ipo-point out ko lang sa code mo:

Code:
textBox1.Text = fileArray ;

hindi ka gumamit ng array index but you're looping with i..

and hindi ka rin nag concatenate ng strings..
 
ipo-point out ko lang sa code mo:

Code:
textBox1.Text = fileArray ;

hindi ka gumamit ng array index but you're looping with i..

and hindi ka rin nag concatenate ng strings..

ok na po mga bossing salamat sa sagot..iniba ko nlng ung code nag directory.getfiles n lang ako then split ko na lang yung path..
salamat ng madami
 
Status
Not open for further replies.

Similar threads

Back
Top