サイト内検索:

深い階層のフォルダ作成

2010年01月23日更新
お気に入りに登録
VBVCJava開発室 > プログラミング > ファイル/フォルダ処理 > 深い階層のフォルダ作成
ファイル/フォルダ処理
  1. docファイル存在チェック
  2. docフォルダ存在チェック
  3. docシーケンシャルファイル書き込み
  4. docシーケンシャルファイル読み込み
  5. docランダムアクセスファイル書き込み
  6. docランダムアクセスファイル読み込み
  7. docINIファイル書き込み
  8. docINIファイル読み込み
  9. doc深い階層のフォルダ作成
  10. doc実行ファイル絶対パス取得
  11. docWindowsフォルダ取得
  12. docスタートアップパス取得
  13. doc共通スタートアップパス取得
  14. docデスクトップのパス取得
  15. doc共通デスクトップのパス取得
  16. docプログラムメニューパス取得
  17. doc共通プログラムメニューパス
  18. doc右クリックの送るのパス取得
  19. docお気に入りのパス取得
メインメニュー
  1. docプログラミング
  2. docサーバ構築
  3. docお薦めの技術書籍/参考書
  4. docパソコンショップ
  5. docサーバーショップ
  6. doc周辺機器
  7. docモニター
  8. doc外部媒体
  9. doc自作パソコン用パーツ
  10. doc契約
  11. doc就職・転職・バイト情報

◆説明◆

深い階層のフォルダを作成するサンプルです。


◆VBの場合◆

Dim i As Integer
Dim strPath As String
Dim strPaths() As String
Dim strTemp As String
strPath = "D:\AAA\BBB\CCC"
strPaths = Split(strPath, "\")
strTemp = strPaths(LBound(strPaths))
For i = LBound(strPaths) + 1 To UBound(strPaths)
strTemp = strTemp + "\" + strPaths(i)
If Dir(strTemp, vbDirectory) = "" Then
Call MkDir(strTemp)
End If
Next


◆VC++の場合◆

char strPath[_MAX_PATH];
char strTemp[_MAX_PATH];
char *pPoint = strPath;
HANDLE hFindFile;
WIN32_FIND_DATA FindFileData;

strcpy(strPath, "D:\\AAA\\BBB\\CCC");
if (strPath[strlen(strPath) - 1] != '\\')
{
strcat(strPath, "\\");
}
while (pPoint = strchr(pPoint + 1, '\\'), pPoint != NULL)
{
strcpy(strTemp, strPath);
strTemp[pPoint - strPath] = '\0';

hFindFile = FindFirstFile(strTemp, &FindFileData);
if (hFindFile == INVALID_HANDLE_VALUE)
{
CreateDirectory(strTemp, NULL);
}
else
{
FindClose(hFindFile);
}
}


◆Javaの場合◆

//"java.io.*"をインポートする必要があります。
// import java.io.*;
String strPath;
File objFile;
strPath = "D:\\AAA\\BBB\\CCC";
objFile = new File(strPath);
objFile.mkdirs();


お気に入りに登録