473,757 Members | 8,085 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Getting path from a StreamReader

I have a function which gets passed a streamreader object as an
argument (I know this might sound a little weird, but it's to avoid
code repetition). My problem is this - given a streamreader object is
it possible to determine the file path the streamreader is referencing?

Jul 21 '05 #1
1 2934
<wa****@gmail.c om> wrote in message
news:11******** **************@ z14g2000cwz.goo glegroups.com.. .
I have a function which gets passed a streamreader object as an
argument (I know this might sound a little weird, but it's to avoid
code repetition). My problem is this - given a streamreader object is
it possible to determine the file path the streamreader is referencing?


Only if the StreamReader is reading a FileStream:

private string GetFileName(Str eamReader reader) {
FileStream fileStream = reader.BaseStre am as FileStream;
if(fileStream != null) {
return fileStream.Name ;
} else {
// Handle no file situation
}
}
Jul 21 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
4507
by: Alex | last post by:
Hello, in my company, we have a diagnostic tool for hardware. Depending on the hardware projcet, a different project configuration is needed. The configuration file is written in XML and contains information for the visualization and storage of the retrieved data. From mid july till now, i have made 4 different configuration sets and everything was fine. Today, i got the order to make a new configuration set. When the xml file was...
1
11288
by: Tom | last post by:
I am trying to access a file in .NET code behind using a StreamREader: StreamReader oTextFile = new StreamReader("\\s1 \\Dest\\123.asp"); But when I run the code, I get this error. Could not find a part of the path "C:\fhlbcinsnp1 \Destination\100597\1622686.asp".
4
5533
by: Mike | last post by:
I created a StreamReader object from a local file on my c:\ drive StreamReader srTemp = new StreamReader("C:\\myFile.txt") I then used a RegEx to strip out all the html and save what's left to a string object So far so good. So now I'm left with just the text Question 1.When I created a second streamreader object and pass in the name of this string I got this erro
3
2000
by: Beryl Small | last post by:
Hi, I have a third party software that needs to send information to an .aspx page for processing to communicate with an SQL database. The software sends the information something like this: Mypage.aspx?Password=Mypassword When this request hits the page, I need to pull that variable Mypassword to use in my VB function to query the database. I'm confused on how to get it. I tried using
4
1814
by: Larry Tate | last post by:
I am wanting to get those cool html error pages that ms produces when I hit an error in asp.net. For instance, when I get a compilation error I get an html error page that shows me the Description: Compiler Error Message: Source Error: Source File: The main thing I want is the Source Error. This give me a few lines of the
1
248
by: waolly | last post by:
I have a function which gets passed a streamreader object as an argument (I know this might sound a little weird, but it's to avoid code repetition). My problem is this - given a streamreader object is it possible to determine the file path the streamreader is referencing?
3
15783
by: Eckhard Schwabe | last post by:
I only found one post on Google where someone mentions the same problem with a DataSet: XmlDataReader in .Net 1.1 can not read XML files from a path which contains "%10" or "%3f". code to reproduce: string filename = "%10.xml"; //XML file with this name is existing XmlReader reader = new XmlTextReader(filename);
1
2285
by: crusson | last post by:
(edited to add): this is in Visual Basic .net I am at a complete loss... I've been building a program on my machine, running it out of the developer with the f5 key and builidng it and running it off of my machine every once in a while. It works perfectly. I built it and sent it to my co worker's machine to test it out and it returns an "Illegal characters in path" error when the line: Dim objReaderOpen1 As New...
2
2053
by: hgarg | last post by:
The onpaint() is getting called before calculating the required parameters by listBox1_SelectedIndexChanged function. I tried calling it at the end of this function. But of no use. Due to this issue only half of the diagram is getting painted,some lines are missing in the diagram. private void listBox1_SelectedIndexChanged(object sender, System.EventArgs e) { string str=listBox1.SelectedItem.ToString(); string str1=null;...
0
10072
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9906
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9885
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8737
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7286
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5172
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5329
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3829
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2698
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.