-1

I have a wpf application and I am saving an Excel file using following code. If I select the file path as "C:\" it throws an error. No other file path has this issue.

Please help.

excelWorkbook.SaveAs(saveAsPath, XlFileFormat.xlWorkbookNormal, Type.Missing,
                            Type.Missing, Type.Missing, Type.Missing, XlSaveAsAccessMode.xlExclusive,
                            Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing);

EDIT

File name: C:\2347_H4141001_axm2312_20110627_042821.xls

The error is:

The file could not be accessed. Try one of the following:

• Make sure the specified folder exists.

• Make sure the folder that contains the file is not read-only.

• Make sure the file name does not contain any of the following characters: < > ? [ ] : | or *

• Make sure the file/path name doesn't contain more than 218 characters.

Simon Adcock
  • 3,554
  • 3
  • 25
  • 41
Relativity
  • 6,690
  • 22
  • 78
  • 128

1 Answers1

-1
  • Do you have checked permissions? Windows blocks writes to ROOT of drives like C: by default.

  • The characters ":" and "\" may be the cause, try to use @ before, like this: @"C:\nameOfFile

zx485
  • 28,498
  • 28
  • 50
  • 59
Frederico Fiuza
  • 127
  • 1
  • 1