简体   繁体   中英

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.

错误记录

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

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.

似乎您正在尝试从Workspace目录中加载“ KT.exe”,但是您将其在父目录中加载到Workspace。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM