분류 | 게시판 |
베스트 |
|
유머 |
|
이야기 |
|
이슈 |
|
생활 |
|
취미 |
|
학술 |
|
방송연예 |
|
방송프로그램 |
|
디지털 |
|
스포츠 |
|
야구팀 |
|
게임1 |
|
게임2 |
|
기타 |
|
운영 |
|
임시게시판 |
|
FileInfo[] arrfileInfo = null;
string[] dirList = Directory.GetDirectories(sourcePath);
if (File.Exists(sourcePath))
{
arrfileInfo = new FileInfo[] { new FileInfo(sourcePath) };
}
else if(Directory.Exists(sourcePath))
{
DirectoryInfo di = new DirectoryInfo(sourcePath);
arrfileInfo = di.GetFiles("*", SearchOption.AllDirectories);
}
foreach (string dir in dirList)
{
string dirName = dir.Substring(dir.LastIndexOf(@"") + 1);
DirectoryInfo Dir = new DirectoryInfo(destPath + dirName);
if (!Dir.Exists)
{
Directory.CreateDirectory(destPath + dirName);
}
}
if (arrfileInfo != null)
{
long total_current = 0;
long total = 0;
// 총 파일 용량
foreach (FileInfo i in arrfileInfo)
{
if ((i.Attributes & FileAttributes.Hidden) != FileAttributes.Hidden)
total += i.Length;
}
foreach (FileInfo i in arrfileInfo)
{
if ((i.Attributes & FileAttributes.Hidden) == FileAttributes.Hidden)
{
continue;
}
FileStream rs = null, ws = null;
try
{
rs = new FileStream(i.FullName, FileMode.Open);
ws = new FileStream(destPath + "//" + i.Name, FileMode.Create);
this.Invoke((SetLabelDelegate)delegate(string fileName)
{
lblFile.Text = fileName;
}, new object[] {i.Name});
int readSize = 0;
while((readSize = rs.Read(buffer, 0, buffer.Length)) != 0)
{
total_current += readSize;
// ProgressBar
int percent = (int)((double)total_current / (double)total * 100);
this.Invoke((SetProgDelegate)delegate(int value)
{
this.pbTransfer.Value = value;
this.lblPer.Text = String.Format("{0}%", value);
},
new object[] { percent });
ws.Write(buffer, 0, readSize);
}
}
catch(Exception e)
{
MessageBox.Show(e.ToString());
}
finally
{
try
{
rs.Close();
}
catch (Exception ex)
{
MessageBox.Show(ex.ToString());
}
try
{
ws.Close();
}
catch (Exception ex)
{
MessageBox.Show(ex.ToString());
}
}
}
this.Invoke((SetProgDelegate)delegate(int value)
{
this.pbTransfer.Value = value;
this.lblPer.Text = String.Format("{0}%", value);
}, new object[] { 100 });
Thread.Sleep(500);
}
this.Invoke((ExitDelegate)delegate()
{
this.DoEnd();
});
이런식으로 해서 파일복사를 했는데..
폴더 생성도 잘 되고 복사도 잘 되는데..
ABC폴더 안에 [A폴더(파일있음), B폴더(파일있음), C.txt] 이런식으로 들어 있을 때
A폴더 생성되고 B 폴더 생성되고 저 생성된 폴더 안에 들어가야할 파일들도 c.txt와 함께 ABC폴더에 복사가 되버렸는데요..
저 부분에서 어떤형태로 수정을 해 줘야 생성된 폴더안으로 파일이 복사가 될까요..;;
맨날 간단한 화면개발만 하다가 이런거 하려니까..;; 공부가 너무 부족했다는 생각이 드네요
게다가 C#은 얼마 해보지 않아서...
죄송합니다. 댓글 작성은 회원만 가능합니다.
번호 | 제 목 | 이름 | 날짜 | 조회 | 추천 | |||||
---|---|---|---|---|---|---|---|---|---|---|
160 | 장갑 옵션은 어느정도 부터 봐야하나요? [7] | 여긴처음이지 | 13/01/08 16:57 | 133 | 0 | |||||
159 | 야만이 키우고 싶어서... | 여긴처음이지 | 13/01/04 23:50 | 17 | 0 | |||||
158 | 참... 이상해요 [2] | 여긴처음이지 | 12/12/30 14:45 | 62 | 0 | |||||
157 | 오오 소소한 득템을 했습니다! [1] | 여긴처음이지 | 12/12/30 00:52 | 84 | 0 | |||||
156 | 질문 하나만 드려봅니다. [3] | 여긴처음이지 | 12/12/29 23:49 | 38 | 0 | |||||
155 | 요르단 반지 엄청 안나오네요.. [3] | 여긴처음이지 | 12/12/27 12:00 | 148 | 0 | |||||
154 | 어... 뭐..뭔가 득을 한 것 같아요 [1] | 여긴처음이지 | 12/12/25 22:17 | 128 | 0 | |||||
153 | 악사 215시간 하면서 키데아가 준 첫 전설 | 여긴처음이지 | 12/12/23 15:20 | 146 | 0 | |||||
152 | 우왕 한 방에서 전설이 두개나 떴네요.. [1] | 여긴처음이지 | 12/12/19 16:08 | 0 | 0 | |||||
151 | 저도 투표하고 왔어요~ [2] | 여긴처음이지 | 12/12/19 09:00 | 0 | 3 | |||||
150 | 투표인증~! | 여긴처음이지 | 12/12/19 08:36 | 0 | 5 | |||||
149 | 흐엉엉.....인나 갑옷 주웠는데..... [1] | 여긴처음이지 | 12/12/18 11:01 | 181 | 0 | |||||
148 | 우어엉 저도 드디어 만티가 생겼네요 [1] | 여긴처음이지 | 12/12/16 14:14 | 122 | 1 | |||||
147 | 전설이 생각보다 잘 뜨네요 | 여긴처음이지 | 12/12/16 12:54 | 162 | 0 | |||||
146 | 방금 처음으로 득을 한 것 같아요 [4] | 여긴처음이지 | 12/12/15 16:17 | 134 | 0 | |||||
145 | 바다와 낙조가 보고 싶어서 다녀왔습니다 | 여긴처음이지 | 12/12/10 23:59 | 9 | 0 | |||||
144 | [WOT]Lorraine39 L AM 이녀석 좋네요 [1] | 여긴처음이지 | 12/12/10 10:45 | 55 | 1 | |||||
143 | 자주포는 역시 어려워용 | 여긴처음이지 | 12/12/07 22:43 | 39 | 0 | |||||
142 | 지옥불반지의 무서움.... | 여긴처음이지 | 12/12/06 23:48 | 115 | 1 | |||||
139 | 어디 간단한 사직서 양식 없나요 [4] | 여긴처음이지 | 12/12/02 22:59 | 30 | 0 | |||||
138 | 가위 게시판에 오신걸 진심으로 환영합니다 | 여긴처음이지 | 12/11/29 12:42 | 25 | 0 | |||||
137 | 갤노트2 질문이요 [2] | 여긴처음이지 | 12/11/29 11:28 | 30 | 0 | |||||
136 | 친구팟은 무서워요... [1] | 여긴처음이지 | 12/11/29 11:20 | 129 | 1 | |||||
135 | 군산 소룡동 근처 잘 아시는분~? [1] | 여긴처음이지 | 12/11/28 11:27 | 43 | 0 | |||||
134 | 아악 [1] | 여긴처음이지 | 12/11/26 20:24 | 16 | 0 | |||||
133 | C# 질문 하나만 드립니다. | 여긴처음이지 | 12/11/23 15:53 | 19 | 0 | |||||
▶ | C# 하고 있는데 길 좀 알려주세요.. [3] | Programmer | 12/11/22 17:07 | 32 | 0 | |||||
131 | 저도 점점 나약해 지는 듯 | Programmer | 12/11/15 21:56 | 22 | 0 | |||||
|
||||||||||
[1] [2] [3] [4] [5] [6] [7] [8] [9] [10] [다음10개▶] | ||||||||||