473,394 Members | 1,854 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

VB.net opening a bitmap and checking to see if it exists first

140 100+
Hi,

I've created a program that opens a bit map and scans the pixels to count up the non-white pixels.

I put the initial open function inside of a try statement, but it fails to hit an error if the file I input doesn't exist. Also, this is a console app, not a GUI one. All the file checking I saw online only worked with the OpenFileDialog.

Here is the snipet of code:
Expand|Select|Wrap|Line Numbers
  1. Dim a As String
  2.  
  3.         For each a in args
  4.             If Prev = "-input" then 
  5.                 InpBmp = a
  6.             End If
  7.               'I removed some unnecessary code here.
  8.             Prev = a
  9.         Next
  10.  
  11.         Try
  12.  
  13.             BitMap_Trim(InpBmp) 'this sub creates a bitmap called cropped.bmp
  14.             b = New Bitmap(AppDomain.CurrentDomain.BaseDirectory & "cropped.bmp")
  15.  
  16.         Catch ex As Exception
  17.             Console.WriteLine("Usage: Bitmap_Area_Calc.exe -input <bitmap name>.bmp -hor <number wide>" & Chr(10))
  18.             Console.WriteLine(" [or -vert <number high>] -step <subarea to calc total>")
  19.             Exit Sub
  20.         End Try
  21.  
Any suggestions as to what I'd need to add to return an error when the file that is opened, doesn't exist?

Thanks,
Sitko.
Oct 21 '07 #1
1 1560
Killer42
8,435 Expert 8TB
I'd recommend using the FileSystemObject. It can easily tell you whether a specified file exists.
Oct 22 '07 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Display Name | last post by:
the customer I'm developing a site for uses a canned form-parsing page that allows her to have an email subscription opt-in page add emails to a list she can manage using a link that you point your...
0
by: Jeff Pritchard | last post by:
This is a twisted little problem. A client has an Access 2000 front-end using linked tables to a DNS to SQL Server 2000 back-end. With an Access 2000 back-end there is no problem. The problem...
4
by: Phil | last post by:
k, here is my issue.. I have BLOB data in SQL that needs to be grabbed and made into a TIF file and placed on the client (could be in temp internet dir). The reason we need it in TIF format is...
2
by: Sharon | last post by:
I encountered a strange behavior when doing ‘new Bitmap’: The following code works fine and the given bitmap file is shown on the PictureBox (the m_DrawArea) in the correct bitmap sizes: ...
6
by: Michael | last post by:
I'm trying to use the Bitmap class's Save Method to save a Bitmap as a GIF. My code runs fine, and converts the image, but the quality is not anywhere close to as good. I know that GIF quality is...
6
by: Dave Harvey | last post by:
I have developed a standard .NET control which displays medical images and works fine in applications, but increasingly, my customers are wishing to use it in an ASP.NET environment, so I am...
14
by: eliss.carmine | last post by:
I'm using TCP/IP to send a Bitmap object over Sockets. This is my first time using C# at all so I don't know if this is the "right" way to do it. I've already found out several times the way I was...
2
by: Peter Oliphant | last post by:
I want to create a new Bitmap which is a portion of an existing Bitmap. For example, if I have a Bitmap that is 100x100 in size I might want to create a new Bitmap that is equivalent to the one...
1
by: geetamadhavi | last post by:
Hi All, I have developed a php applciaiton where a new window is opening on checking the whether valid user orntot how to make that in same window after checking i have die(' not valid user ' ); i...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
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...
0
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...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.