mchicago
mchicago

Reputation: 800

c# WINFORM file asscociation issue

I have WinForm application which is almost ready to go for production and here is the problem that I am facing and I am not able to resolve it.

Secondly sorry to post an image of the error log instead of actual text for that.

I am sort of new user of stack overflow and could not fix the formatting issue at all.

File Test.DAT is associated with KT.exe. But upon trying to open Test.DAT using KT.exe an exception is thrown. (please see attached image...again sorry for the image).

I created a sample windows application which works fine but this one does not.

So, I am totally confused about what's wrong with it?

So, now back to the problem. Look at the following file structure:

C:\PTS\KT\KT.ext
C:\PTS\KT\log4.net
C:\PTS\KT\Workspace\test.DAT

Can someone please help me to resolve this issue?

SOLUTION: Sorry for raising false alarm. Actually to get assembly information I was loading KT.exe inside Main() using Assembly.LoadForm("KT.exe") which was throwing error. I updated the code to Assembly assembly = Assembly.GetExecutingAssembly(); I can't believe that it took so long to figure out this.

Error log

Upvotes: 0

Views: 193

Answers (3)

mchicago
mchicago

Reputation: 800

SOLUTION: Sorry for raising false alarm. Actually to get assembly information I was loading KT.exe inside Main() using Assembly.LoadForm("KT.exe") which was throwing error. I updated the code to Assembly assembly = Assembly.GetExecutingAssembly(); I can't believe that it took so long to figure out this.

Upvotes: 0

competent_tech
competent_tech

Reputation: 44921

Your problem is that the file association does not include the full path to kt.exe, only the file name. So when you open the file in the Workspace dir, the operating system tries to find kt.exe there as well.

You can test this by moving the .dat file from workspace into the same directory as kt.exe, then double-click on it.

Update:

To re-associate the file with your program, take the following steps:

1) Open a command prompt

2) Clear the existing association by entering:

ASSOC .dat= 

3) Create a new file type entry for your app by entering:

FTYPE KTDatFile="c:\pts\kt\kt.exe" %1 %*

4) Associate the new file type with your extension by entering:

ASSOC .dat=KTDatFile

Upvotes: 1

Wizetux
Wizetux

Reputation: 756

It appears that you are attempting to load the "KT.exe" from the Workspace directory but you have it in the parent directory to Workspace.

Upvotes: 0

Related Questions