Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3482090
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T10:31:08+00:00 2026-05-18T10:31:08+00:00

I have a WinForms application and I am looking for a way to do

  • 0

I have a WinForms application and I am looking for a way to do the following:

  1. Click link to create a Word document from a BLOB in the database and open it.
  2. Block the WinForms application until Word is closed.
  3. Handle when Word is closed, check if the document was changed, and persist changes to the database.

The problem I am having is not creating the Word document and opening it, but it is hooking to the Word process to know when Word has closed. Is there some libraries to look at for doing this or any tutorials that would show how to accomplish this task?

Please see accepted solution, but here is the code I used to complete my task:

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."); 
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-18T10:31:09+00:00Added an answer on May 18, 2026 at 10:31 am

    You can wait for a process to close using the following code:

    process.WaitForExit();
    

    when word will close, you can check if the file is modified and store it in database.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a C# Winforms application I'm looking to deploy on an XP Laptop
I have a winforms application and I am trying to create a method that
I have a winforms Application, On Close button click, I am hiding that application
I have a desktop(winforms) application, and I'm looking for .net linker that links the
I have been looking at Prism to host an old Winforms application. This is
I am looking for best practices in regards to printing from a WinForms application.
We have a typical business application with an Outlook-looking Winforms client talking to asmx
I have a Winforms application (written in C#) that is deployed on a network
I have a WinForms application, with login form, and I want to store the
I have a WinForms application (WF), and a Library called by that WinForms application

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.