Kavitha
Kavitha

Reputation: 1467

The given path's format is not supported in windows app

I tried to get file path using below code.

string script = File.ReadAllText(Application.StartupPath + "D:\\Tax Rouding   Projects\\10-12-12 TaxRoundingUtility\\TaxRoundingUtility\\Scripts\\GP_SOP_AdjustTax.sql");

But i am getting error : The given path's format is not supported

if i try to open the file from windows explorer.. i am able to go file location..

D:\Tax Rouding Projects\10-12-12 TaxRoundingUtility\TaxRoundingUtility\Scripts\

But why i cannot using c# code...

Any thing i missed in the path...

Upvotes: 0

Views: 1621

Answers (1)

Ravi Y
Ravi Y

Reputation: 4376

The problem lies here

Application.StartupPath + "D:\Tax Rouding Projects\10-12-12 TaxRoundingUtility\TaxRoundingUtility\Scripts\GP_SOP_AdjustTax.sql"

This might end up giving you something like

"c:\program files\myappfolder\D:\Tax Rouding Projects\10-12-12 TaxRoundingUtility\TaxRoundingUtility\Scripts\GP_SOP_AdjustTax.sql"

which is an invalid path. Append only portion of path that you need like (the second part is just an example)

Application.StartupPath + @"\TaxRoundingUtility\Scripts\GP_SOP_AdjustTax.sql".

Also make sure to escape the '\' in your file path strings.

Edit: As Dante has mentioned in the comment in the question, If your target path is fixed and known, you do not need the Application.StartppPath. Just load/read the file for which you have the complete path.

Upvotes: 1

Related Questions