• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Extracting file name & path from NSOpenPanel
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Extracting file name & path from NSOpenPanel


  • Subject: Extracting file name & path from NSOpenPanel
  • From: Phil Faber <email@hidden>
  • Date: Sun, 2 Apr 2006 19:20:50 +0100

Hi all.

I'm a newbie and I am trying to figure out how to prompt the user to select a file name, and then display that name (including path) in an Alert box. (The alert box is only used to see if the code was successful - eventually it will be replaced by something more useful!)

I've managed to get as far as this code (which displays the file's CONTENTS), but how can I get at the file NAME and path?

Thanks!

-
	// Select file to compress

{
// Create and display an open panel.
NSOpenPanel *panel = [NSOpenPanel openPanel];
int result = [panel runModalForDirectory:nil file:nil types:nil];

// Quit if user pressed cancel.
if ( result == NSFileHandlingPanelCancelButton )
{
[NSApp terminate:self];
}

// Read the file and put it in the text view.
NSString *content = [NSString stringWithContentsOfFile:[panel filename]];


		NSRunAlertPanel(@"File name selected was:",content,@"OK",NULL,NULL);
	}

-

_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


  • Follow-Ups:
    • Re: Extracting file name & path from NSOpenPanel
      • From: Mike Abdullah <email@hidden>
  • Prev by Date: Core Data: How do you count records in a persistent store?
  • Next by Date: Tiger Intel AS Studio, eSellerate Integrated to Embedded transition
  • Previous by thread: Re: Core Data: How do you count records in a persistent store?
  • Next by thread: Re: Extracting file name & path from NSOpenPanel
  • Index(es):
    • Date
    • Thread