Solved

Upgrading code from Vb.NET 2003 to 2008 , Narrowing Conversion?

Posted on 2007-12-04
4
489 Views
Last Modified: 2013-11-26
I'm upgrading my vb.net code from 2003 to 2008. I'm getting a narrowing conversion error on the 4th line. Any ideas?

Dim fs As FileStream
                Dim sr As StreamReader
                Try
                    fs = New System.IO.FileStream(flXML, System.IO.FileMode.Open, System.IO.FileShare.ReadWrite, FileShare.Read)
 
                    sr = New System.IO.StreamReader(fs)
 
 
                    DSet.ReadXml(sr)
                    sr.Close()
                    fs.Close()

Open in new window

0
Comment
Question by:JPERKS1985
4 Comments
 
LVL 96

Expert Comment

by:Bob Learned
ID: 20404948
What is 'flXML' defined as?

Bob
0
 
LVL 1

Author Comment

by:JPERKS1985
ID: 20404958
flXML is just string type, it has the file path to the xml document.
0
 
LVL 18

Expert Comment

by:jcoehoorn
ID: 20404969
A narrowing conversion is when you convert from one data type to another, and the source datatype is larger than the destination type.  Like converting a 64-bit number to a 32-bit number.  This should typically produce a compiler warning, but should generally work.   It will produce an error at compile time if you've told the compiler to report warnings as errors or at runtime if you try to convert a value that won't fit in the smaller type (say, the source variable has a number larger than will fit in your 32bit destination, but less than the max 64bit value).  

What is flXML, and where did it come from?  Looking at the various overloads (my system only has .Net 2.0, so there may be some new options in 3.5) it's likely either a String, IntPtr, or SafeFileHandle.  I'm guessing an IntPtr, since that would be susceptible to the conversion problem.
0
 
LVL 7

Accepted Solution

by:
photowhiz earned 500 total points
ID: 20405005
The third param to new FileStream is a FileAccess, not a FileShare.

Also, you should use Imports System.IO
0

Featured Post

The New “Normal” in Modern Enterprise Operations

DevOps for the modern enterprise offers many benefits — increased agility, productivity, and more, but digital transformation isn’t easy, especially if you’re not addressing the right issues. Register for the webinar to dive into the “new normal” for enterprise modern ops.

Question has a verified solution.

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

Flash (http://en.wikipedia.org/wiki/Adobe_Flash) has evolved over the years to where it has become a masterful tool for displaying content screen.  It has excellent layout placement, UI precision as well as rendering capabilities. This, along with t…
More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

809 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