Tech or Treat! Write an article about your scariest tech disaster to win gadgets!Learn more

x
?
Solved

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

Posted on 2007-12-04
4
Medium Priority
?
494 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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:Joel Coehoorn
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 2000 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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Welcome my friends to the second instalment and follow-up to our Minify and Concatenate Your Scripts and Stylesheets (http://www.experts-exchange.com/Programming/Languages/.NET/ASP.NET/A_4334-Minify-and-Concatenate-Your-Scripts-and-Stylesheets.html)…
In my previous article (http://www.experts-exchange.com/Programming/Languages/.NET/.NET_Framework_3.x/A_4362-Serialization-in-NET-1.html) we saw the basics of serialization and how types/objects can be serialized to Binary format. In this blog we wi…
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …

647 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