0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

GetDirectoriesのワイルドカードで文字数は制限できない

Posted at

目的の処理

あるディレクトリのサブディレクトリから最新を取得したい。
サブディレクトリは日時(yyyyMMddHHmmss)とになっている。
作業用フォルダ(TempyyyyMMddHHmmss)があることもあるがそれは除外する。
つまり14文字のフォルダ名で一番大きいフォルダ名を取得したい。

20160111031203
20160315112315
20160323231822
20160402095559
20160415060703
Temp20160419105509

上記であれば、
20160415060703
を取得する。

書いた処理

My.Computer.FileSystem.GetDirectories(root, FileIO.SearchOption.SearchTopLevelOnly, "?????????????").OrderBy(Function(v) v).LastOrDefault())

ワイルドカードで14文字に限定した。

処理結果

取得できたフォルダは意図していない
Temp20160419105509
だった。

理由(推測)

ワイルドカードの中に固定の文字が無いと検索できない?
つまり今回の場合は*を置いているのと同じ状態??
実際ワイルドカードを、
"??????15??????"
としたところ
20160315112315
20160415060703
が取得できた。

この部分の仕様がどこにあるのかわからない。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?