Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > C# and C > C# 1.0 > C#
Password Reminder
Register
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
C# Programming questions specific to the Microsoft C# language. See also the forum Beginning Visual C# to discuss that specific Wrox book and code.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the C# section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old March 4th, 2004, 02:31 PM
Authorized User
 
Join Date: Jun 2003
Location: Rio de Janeiro, Rio de Janeiro, Brazil.
Posts: 58
Thanks: 0
Thanked 0 Times in 0 Posts
Default excluding archives of a folder

Hi;

How can i exclude a file of a folder???

Can i use the DELETE or REMOVE method???

There is another way to do this????

Thanks
Reply With Quote
  #2 (permalink)  
Old March 4th, 2004, 05:23 PM
planoie's Avatar
Friend of Wrox
Points: 16,481, Level: 55
Points: 16,481, Level: 55 Points: 16,481, Level: 55 Points: 16,481, Level: 55
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Aug 2003
Location: Clifton Park, New York, USA.
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

To what context are you referring? You haven't provided a whole lot of useful information here.
Reply With Quote
  #3 (permalink)  
Old March 5th, 2004, 09:23 AM
Authorized User
 
Join Date: Jun 2003
Location: Rio de Janeiro, Rio de Janeiro, Brazil.
Posts: 58
Thanks: 0
Thanked 0 Times in 0 Posts
Default

To Planoie;

First I would like to thank the attention….

I have a program that save archives like (*.gif, *.JPG) in a folder of my C driver (C:\TESTE\FIGURAS).

To save the picturebox image in my Hard Drive i use the SAVE method. For example (this.pctImagem.Image.Save (CaminhoEscolhido);).

This process functions very well.

But now i want to create a button that give me the option to exclude an image in my hard drive, and according to my research the methods DELETE and REMOVE are used to exclude an image from a picturebox. I dont know the correct method to exclude an archive of a folder in a hard drive.

I would like to know the correct way to exclude files from a hard disk according to a path that passed with parameter for the method.

Since already very obliged
Reply With Quote
  #4 (permalink)  
Old March 5th, 2004, 10:53 AM
Authorized User
 
Join Date: Nov 2003
Location: Milwaukee, Wisconsin, USA.
Posts: 24
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to KABay
Default

Your requirements are still not clear but I would like to take a stab at what I think you mean.

You know how to add and remove images from your picturebox, right? So you have no problems there.

I assume you load your picture box by iterating through all of the files in a specified directory and either directly (press a button and display the next/previous image) or indirectly (having loaded a list box with image names/filespecs) display the appropriate image.

Since you can 'save' an Image object to disk you are hoping there is a way to tell the Image object to go find its instance on the hard drive and remove it.

It can't be done (that way). An Image is a object in memory. It may or may not have a serialized/physical version on the hard drive so it would violate object-orientated concepts for an Image object to 'handle' Stream activities. The file is a physical object on the hard drive. To delete it you must go find it on the hard drive:
Code:
    // Get the files from the directory
    System.IO.FileInfo[] files = dirInfo.GetFiles("*.jpg");

    // Add each file name and full name including path
    // to the ListView.
    if (files != null)
    {
        foreach ( System.IO.FileInfo file in files )
        {
            if (file.Name == sNameOfFileToDelete) 
            {
                // You found it so delete it ...
                file.Delete;
                // ... and you are done so 
                //  jump out of the for...each loop
                break;
            }
        }
    }
Reply With Quote
  #5 (permalink)  
Old March 8th, 2004, 09:09 AM
Authorized User
 
Join Date: Jun 2003
Location: Rio de Janeiro, Rio de Janeiro, Brazil.
Posts: 58
Thanks: 0
Thanked 0 Times in 0 Posts
Default

THANKS for your replay;

You it obtained to perceive my problem accurately and show me the solution to my problem.

Thanks;

Quote:
quote:Originally posted by KABay
 Your requirements are still not clear but I would like to take a stab at what I think you mean.

You know how to add and remove images from your picturebox, right? So you have no problems there.

I assume you load your picture box by iterating through all of the files in a specified directory and either directly (press a button and display the next/previous image) or indirectly (having loaded a list box with image names/filespecs) display the appropriate image.

Since you can 'save' an Image object to disk you are hoping there is a way to tell the Image object to go find its instance on the hard drive and remove it.

It can't be done (that way). An Image is a object in memory. It may or may not have a serialized/physical version on the hard drive so it would violate object-orientated concepts for an Image object to 'handel' Stream activities. The file is a physical object on the hard drive. To delete it you must go find it on the hard drive:
Code:
    // Get the files from the directory
    System.IO.FileInfo[] files = dirInfo.GetFiles("*.jpg");

    // Add each file name and full name including path
    // to the ListView.
    if (files != null)
    {
        foreach ( System.IO.FileInfo file in files )
        {
            if (file.Name == sNameOfFileToDelete) 
            {
                // You found it so delete it ...
                file.Delete;
                // ... and you are done so 
                //  jump out of the for...each loop
                break;
            }
        }
    }
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
What is the common way to show archives in weblog? danielxix C# 3 July 7th, 2006 06:18 PM
Excluding Rows fs22 SQL Language 2 August 17th, 2005 12:58 PM
Getting data from WipZip archives elansolutionsltd Access VBA 1 November 20th, 2004 01:47 PM
excluding html from printer .. qwjunk Classic ASP Basics 1 February 3rd, 2004 04:09 PM
Excluding items with certain keywords ashcarrot SQL Language 4 July 23rd, 2003 10:04 AM



All times are GMT -4. The time now is 06:26 PM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.