一个取上级目录的问题? |
答題得分者是:pceyes
|
glings
一般會員 發表:18 回覆:9 積分:5 註冊:2006-07-17 發送簡訊給我 |
|
pceyes
尊榮會員 發表:70 回覆:657 積分:1140 註冊:2003-03-13 發送簡訊給我 |
// 取得目前所在路徑字串之父路徑
// Ex. C:\Parent\Child -> C:\Parent\ // c:\parent\child\son -> C:\parent\child\ function TForm1.parantdir(source_str : widestring):string; var new_str : string; // 父路徑 new_st : tstringlist; // 切割路徑之暫存 icnt : integer; // 次數計算 begin result := ''; // Initize Result new_st := tstringlist.create; try // 切割字串 while Pos('\', source_str) > 0 do begin source_str := trim(source_str); new_st.Add(trim(copy(source_str,1,pos('\',source_str)-1))); delete(source_str,1,pos('\',source_str)); end; // while // 重新排列 new_str := ''; // Initize New_Str for icnt := 0 to new_st.count-2 do begin new_str := new_str new_st[icnt] '\'; end; // for iCnt result := new_str ; finally new_st.Free; end; // Tstringlist.Create try end;
------
努力會更接近成功 |
glings
一般會員 發表:18 回覆:9 積分:5 註冊:2006-07-17 發送簡訊給我 |
本站聲明 |
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。 2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。 3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇! |