나는 윈폼 응용 프로그램을하고 난 다음을 수행 할 수있는 방법을 찾고 있어요 : 데이터베이스에 BLOB에서 Word 문서를 만들고 엽니 다WinForms 응용 프로그램에서 Word 닫기 이벤트를 처리하는 방법?
- 클릭 링크를.
- Word가 닫힐 때까지 WinForms 응용 프로그램을 차단하십시오.
- Word가 닫힐 때 핸들이 문서가 변경되었는지 확인하고 변경 내용을 데이터베이스에 유지합니다.
문제는 Word 문서를 만들고 열고 여는 것이 아니라 Word가 닫힌 시점을 알기 위해 Word 프로세스에 연결하는 것입니다. 이 작업이나이 작업을 수행하는 방법을 보여줄 자습서를 보려는 라이브러리가 있습니까?
하는 것은 허용 솔루션을 볼 수 있지만 여기 내 작업을 완료하는 데 사용되는 코드입니다하십시오
process.WaitForExit();
때 단어 :
protected static string FilePath { get; set; }
public static void DisplayDocument(byte[] documentBytes, string filePath)
{
FilePath = filePath;
if (documentBytes == null) return;
if (!Directory.Exists(TEMP_FILE_DIRECTORY))
Directory.CreateDirectory(TEMP_FILE_DIRECTORY);
if (File.Exists(FilePath)) File.Delete(FilePath);
try
{
FileStream fs = new FileStream(FilePath, FileMode.Create);
fs.Write(documentBytes, 0, Convert.ToInt32(documentBytes.Length));
fs.Seek(0, SeekOrigin.Begin);
fs.Close();
ProcessStartInfo psi = new ProcessStartInfo(FilePath);
Process process = Process.Start(psi);
process.EnableRaisingEvents = true;
process.Exited += process_Exited;
process.WaitForExit();
}
catch (Exception e)
{
MessageHandler.Show(e.Message, Strings.ErrorOpeningFile);
}
}
private static void process_Exited(object sender, EventArgs e)
{
FileInfo fileInfo = new FileInfo(FilePath);
if(fileInfo.CreationTime.CompareTo(fileInfo.LastWriteTime) < 0)
Debug.WriteLine("File updated, perform database upload here.");
}
질문을 시작하려면 어떻게 시작해야합니까? –