既存のアプリ:検索を実行して一致するリードファイルをフェッチし、それらを特定のディレクトリにスローするC#アプリがあります。
機能の追加:ファイルの郵便番号のサブディレクトリが存在するかどうかをシステムで確認し、存在しない場合は作成します。ファイルをそれぞれのディレクトリに転送します。
問題:現在、ファイルは転送されておらず、サブディレクトリも作成されていません。何も起こりません。それは構文の問題ですか、それとも私はそれを間違って呼んでいますか?
助けてください!
これが私が追加したものです:
string targetzipdir = m_sc.get_TargetPath() + "\\" + ZIP;
// If the zip code subdirectory doesn't exist, create it.
if (!Directory.Exists(targetzipdir))
{
Directory.CreateDirectory(targetzipdir);
}
private void TransferFile(string sourceDir, string filename, string ZIP)
{
string targetFileAndPath = m_sc.get_TargetPath() + "\\" + ZIP + "\\" + fullFileName;
SearchProcess.csファイルのコードの詳細は次のとおりです(一部は省略されています)。
public void Run()
{
m_sc = (SearchCriteria)m_form.Invoke(m_form.m_DelegateGetSearchCriteria);
// Display parameters
m_form.Invoke(m_form.m_DelegateAddString, new Object[] { "Search on Corp: " + m_sc.get_Corp() });
m_form.Invoke(m_form.m_DelegateAddString, new Object[] { "Search on OrderNumber: " + m_sc.get_OrderNumber() });
m_form.Invoke(m_form.m_DelegateAddString, new Object[] { "Search on Campaign: " + m_sc.get_Campaign() });
m_form.Invoke(m_form.m_DelegateAddString, new Object[] { "Search on City: " + m_sc.get_City() });
m_form.Invoke(m_form.m_DelegateAddString, new Object[] { "Search on State: " + m_sc.get_State() });
m_form.Invoke(m_form.m_DelegateAddString, new Object[] { "Search on Zip: " + m_sc.get_Zip() });
m_form.Invoke(m_form.m_DelegateAddString, new Object[] { "Search on Source Path: " + m_sc.get_SourcePath() });
m_form.Invoke(m_form.m_DelegateAddString, new Object[] { "Search on Target Path: " + m_sc.get_TargetPath() });
DirSearch(m_sc.get_SourcePath());
// Make asynchronous call to main form
// to inform it that thread finished
m_form.Invoke(m_form.m_DelegateThreadFinished, null);
}
for (int colNum = 0; colNum < expectedTypes.Count; colNum++)
{
if (m_sc.get_SearchOR().Equals(true))
// Check for the Zip match
if (m_sc.get_Zip() != "" && ZIP.Contains(m_sc.get_Zip()) == true)
{
found = true;
string targetzipdir = m_sc.get_TargetPath() + "\\" + ZIP;
// If the zip code subdirectory doesn't exist, create it.
if (!Directory.Exists(targetzipdir))
{
Directory.CreateDirectory(targetzipdir);
}
} // ending if (m_sc.get_SearchOR().Equals(true))
} //ending for loop
private void TransferFile(string sourceDir, string filename, string ZIP)
{
string fullFileName = filename + ZIP + ".pdf";
string fullFileNameAndPath = sourceDir + "\\" + fullFileName;
//copy matching source file into the specified subdirectory based on zip
string targetFileAndPath = m_sc.get_TargetPath() + "\\" + ZIP + "\\" + fullFileName;
// Copy the file if the source file exists
if (File.Exists(fullFileNameAndPath))
{
m_form.Invoke(m_form.m_DelegateAddString, new Object[] {"COPYING FROM: " + fullFileNameAndPath});
m_form.Invoke(m_form.m_DelegateAddString, new Object[] {"TO: " + targetFileAndPath});
// Do the copy, overrite the target file if it exists
File.Copy(fullFileNameAndPath, targetFileAndPath, true);
}
else
{
m_form.Invoke(m_form.m_DelegateAddString, new Object[] {"Source file does not exist: " + fullFileNameAndPath});
}
m_form.Invoke(m_form.m_DelegateAddString, new Object[] {""});
}
見てくれてありがとう!どんなアイデアでも大歓迎です!:)