Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Path of Workbook

Posted on 2016-10-05
3
Medium Priority
?
99 Views
Last Modified: 2016-10-05
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))
                {
                    
                    using (SpreadsheetDocument doc = SpreadsheetDocument.Open(fs, false))
                    {
                        WorkbookPart workbookPart = doc.WorkbookPart;
                        ...

Open in new window

How?
0
Comment
Question by:HuaMinChen
  • 2
3 Comments
 
LVL 52

Expert Comment

by:Gustav Brock
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 11

Author Comment

by:HuaMinChen
ID: 41829610
Sorry, using this

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

Open in new window


I do not get its full path.
0
 
LVL 52

Accepted Solution

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

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

/gustav
0

Featured Post

[Webinar] Cloud and Mobile-First Strategy

Maybe you’ve fully adopted the cloud since the beginning. Or maybe you started with on-prem resources but are pursuing a “cloud and mobile first” strategy. Getting to that end state has its challenges. Discover how to build out a 100% cloud and mobile IT strategy in this webinar.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Do you use a spreadsheet like Microsoft's Excel?  Have you ever wanted to link out to a non excel file on your computer or network drive?  This is the way I found to do it!
This article describes a serious pitfall that can happen when deleting shapes using VBA.
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…
Graphs within dashboards are meant to be dynamic, representing data from a period of time that will change each time the dashboard is updated with new data. Rather than update each graph to point to a different set within a static set of data, t…

972 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question