Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
G
GetAdocUI
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
QCD
Tools
GetAdocUI
Commits
e9f2953b
Commit
e9f2953b
authored
Nov 24, 2021
by
AP matsuo koji
😲
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
#11 既存の生成物がテンポラリフォルダに存在するとアプリケーションが停止する
再修正:異なるドライブの時は、フォルダの移動に失敗します。 ディレクトリ移動を別関数
parent
91f88fdc
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
52 additions
and
5 deletions
+52
-5
RunBatch.cs
GetADoc/RunBatch.cs
+52
-5
No files found.
GetADoc/RunBatch.cs
View file @
e9f2953b
...
@@ -95,19 +95,66 @@ namespace GetADoc
...
@@ -95,19 +95,66 @@ namespace GetADoc
static
public
void
MoveProduct
(
bool
icon
,
bool
sepa
,
static
public
void
MoveProduct
(
bool
icon
,
bool
sepa
,
string
fileName
,
string
tempPath
,
string
filePath
)
string
fileName
,
string
tempPath
,
string
filePath
)
{
{
/*
個別移動ではなく、フォルダ全体を移動した方がよいが、とりあえずそのまま。理由:内部コマンドで生成物が増えたらまた追加修正が必要である。
*/
File
.
Move
(
System
.
IO
.
Path
.
Combine
(
tempPath
,
fileName
+
".adoc"
),
filePath
+
fileName
+
".adoc"
);
File
.
Move
(
System
.
IO
.
Path
.
Combine
(
tempPath
,
fileName
+
".adoc"
),
filePath
+
fileName
+
".adoc"
);
File
.
Move
(
System
.
IO
.
Path
.
Combine
(
tempPath
,
"config.adoc"
),
System
.
IO
.
Path
.
Combine
(
filePath
,
"config.adoc"
));
File
.
Move
(
System
.
IO
.
Path
.
Combine
(
tempPath
,
"config.adoc"
),
System
.
IO
.
Path
.
Combine
(
filePath
,
"config.adoc"
));
Directory
.
Move
(
System
.
IO
.
Path
.
Combine
(
tempPath
,
"Images"
),
System
.
IO
.
Path
.
Combine
(
filePath
,
"Images"
));
MoveDirectory
(
System
.
IO
.
Path
.
Combine
(
tempPath
,
"Images"
),
System
.
IO
.
Path
.
Combine
(
filePath
,
"Images"
));
// Directory.Move -> local MoveDirectory
if
(
icon
==
true
)
if
(
icon
==
true
)
{
{
Directory
.
Move
(
System
.
IO
.
Path
.
Combine
(
tempPath
,
"icons"
),
System
.
IO
.
Path
.
Combine
(
filePath
,
"icons"
));
MoveDirectory
(
System
.
IO
.
Path
.
Combine
(
tempPath
,
"icons"
),
System
.
IO
.
Path
.
Combine
(
filePath
,
"icons"
));
// Directory.Move -> local MoveDirectory
}
}
if
(
sepa
==
true
)
if
(
sepa
==
true
)
{
{
File
.
Move
(
System
.
IO
.
Path
.
Combine
(
tempPath
,
"IncDoc.adoc"
),
System
.
IO
.
Path
.
Combine
(
filePath
,
"IncDoc.adoc"
));
File
.
Move
(
System
.
IO
.
Path
.
Combine
(
tempPath
,
"IncDoc.adoc"
),
System
.
IO
.
Path
.
Combine
(
filePath
,
"IncDoc.adoc"
));
Directory
.
Move
(
System
.
IO
.
Path
.
Combine
(
tempPath
,
"Sub_First"
),
System
.
IO
.
Path
.
Combine
(
filePath
,
"Sub_First"
));
MoveDirectory
(
System
.
IO
.
Path
.
Combine
(
tempPath
,
"Sub_First"
),
System
.
IO
.
Path
.
Combine
(
filePath
,
"Sub_First"
));
// Directory.Move -> local MoveDirectory
Directory
.
Move
(
System
.
IO
.
Path
.
Combine
(
tempPath
,
"Sub_Second"
),
System
.
IO
.
Path
.
Combine
(
filePath
,
"Sub_Second"
));
MoveDirectory
(
System
.
IO
.
Path
.
Combine
(
tempPath
,
"Sub_Second"
),
System
.
IO
.
Path
.
Combine
(
filePath
,
"Sub_Second"
));
// Directory.Move -> local MoveDirectory
}
}
}
}
/// <summary>
/// ディレクトリを移動する。
/// </summary>
/// <param name="sourceDirName">移動するディレクトリ</param>
/// <param name="destDirName">移動先のディレクトリ</param>
/*
ref: https://johobase.com/copy-directory-csharp/ [ディレクトリ(フォルダー)をコピーする [C#]]
最後に追加して、移動元のディレクトリをサブディレクトリ、ファイルを含めて削除
Directory.Delete(sourceDirName, true);
*/
public
static
void
MoveDirectory
(
string
sourceDirName
,
string
destDirName
)
{
// コピー先のディレクトリがないかどうか判定する
if
(!
Directory
.
Exists
(
destDirName
))
{
// コピー先のディレクトリを作成する
Directory
.
CreateDirectory
(
destDirName
);
}
// コピー元のディレクトリの属性をコピー先のディレクトリに反映する
File
.
SetAttributes
(
destDirName
,
File
.
GetAttributes
(
sourceDirName
));
// ディレクトリパスの末尾が「\」でないかどうかを判定する
if
(!
destDirName
.
EndsWith
(
Path
.
DirectorySeparatorChar
.
ToString
()))
{
// コピー先のディレクトリ名の末尾に「\」を付加する
destDirName
=
destDirName
+
Path
.
DirectorySeparatorChar
;
}
// コピー元のディレクトリ内のファイルを取得する
string
[]
files
=
Directory
.
GetFiles
(
sourceDirName
);
foreach
(
string
file
in
files
)
{
// コピー元のディレクトリにあるファイルをコピー先のディレクトリにコピーする
File
.
Copy
(
file
,
destDirName
+
Path
.
GetFileName
(
file
),
true
);
}
// コピー元のディレクトリのサブディレクトリを取得する
string
[]
dirs
=
Directory
.
GetDirectories
(
sourceDirName
);
foreach
(
string
dir
in
dirs
)
{
// コピー元のディレクトリのサブディレクトリで自メソッド(CopyDirectory)を再帰的に呼び出す
MoveDirectory
(
dir
,
destDirName
+
Path
.
GetFileName
(
dir
));
}
Directory
.
Delete
(
sourceDirName
,
true
);
// 追加: 最後に元のフォルダを削除する
}
}
}
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment