Solved

# Path of Workbook

Posted on 2016-10-05
45 Views
Hi,
I want to know relevant path of the Workbook, per given codes below
``````                using (FileStream fs = new FileStream(openFileDialog1.FileName, FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
{

{
WorkbookPart workbookPart = doc.WorkbookPart;
...
``````
How?
0
Question by:HuaMinChen
• 2

LVL 49

Expert Comment

ID: 41829566
The workbook file would be

workbookFile = Path.GetFileName(openFileDialog1.FileName);

so you will have to use lesser obtuse code for your first code line.

/gustav
0

LVL 10

Author Comment

ID: 41829610
Sorry, using this

``````string Path0 = Path.GetFileName(openFileDialog1.FileName);
``````

I do not get its full path.
0

LVL 49

Accepted Solution

Gustav Brock earned 500 total points
ID: 41829616
Sorry, missed that:

string fullPath = openFileDialog1.FileName;
string folderOnly = Path.GetDirectoryName(openFileDialog1.FileName);

/gustav
0

## Featured Post

### Suggested Solutions

A little background as to how I came to I design this code: Around 5 years ago I designed an add-in that formatted Excel files to a corporate standard, applying different cell colours and font type depending on whether the cells contained inputs,…
Performance in games development is paramount: every microsecond counts to be able to do everything in less than 33ms (aiming at 16ms). C# foreach statement is one of the worst performance killers, and here I explain why.
The viewer will learn how to use a discrete random variable to simulate the return on an investment over a period of years, create a Monte Carlo simulation using the discrete random variable, and create a graph to represent the possible returns over…
The viewer will learn how to create a normally distributed random variable in Excel, use a normal distribution to simulate the return on an investment over a period of years, Create a Monte Carlo simulation using a normal random variable, and calcul…