Link to home
Start Free TrialLog in
Avatar of JPERKS1985
JPERKS1985

asked on

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

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

Avatar of Bob Learned
Bob Learned
Flag of United States of America image

What is 'flXML' defined as?

Bob
Avatar of JPERKS1985
JPERKS1985

ASKER

flXML is just string type, it has the file path to the xml document.
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.
ASKER CERTIFIED SOLUTION
Avatar of photowhiz
photowhiz
Flag of Canada image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial