954,525 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

opening a file from a filename stored in a textbx

hi,

I have created an application which allows users to view pictures, basically i want to know if it is possible for the file path to be displayed in a text box and for a user to be able to launch the picture using this file name in the text box.

currently I have an open file dialog to open pictures but want to know whether it is possible to open pictures this way instead.

thanks,

jakkee
Newbie Poster
5 posts since Mar 2010
Reputation Points: 10
Solved Threads: 0
 

Yes,

it is possible, but you should show what you have tried till now, before you can expect an how-to-do-this answer.

rozendaa@xs4all
Newbie Poster
7 posts since Sep 2007
Reputation Points: 11
Solved Threads: 4
 

I suppose you use a PictureBox, so use ImageLocation property to display the path of the current picture and .Load(textbox1.text) to open the picture.

Ionut

Ionelul
Junior Poster in Training
94 posts since Dec 2009
Reputation Points: 17
Solved Threads: 27
 

Thanks,

works great now

jakkee
Newbie Poster
5 posts since Mar 2010
Reputation Points: 10
Solved Threads: 0
 

Here I know this is alittle off but I created a code that did something like this except that I preloaded the pictures into the application and when you clicked on them they would open and go full screen (this is meant to run on vista default picture viewer). I hope this can help you alittle

Screenshot of the application
http://i109.photobucket.com/albums/n65/Vin_diesalxxx/PhotpresenterC.png

Each of those pictures is a picture box, also in the code below I copied the files into the .../Document/Visual Studio 20**/Projects///bin/debug

I hope this can help or atleast give you ideas. (Also those pics were uploaded into pictureBox items, might help you on the right path with those)

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.IO;
using System.Diagnostics;

namespace PhotoPresentApp
{
    public partial class Form1 : Form
    {
        public Form1()
        {
         InitializeComponent();
        }

        private void pictureBox1_Click(object sender, EventArgs e)
         {
          string input = "Pic1.jpg"; //file name
          Process newProc = Process.Start(input); //Vista default opens JPG pictures in 
                                                  //it a photo view I believe is called
                                                  //Windows Photo Gallery Viewer, can't
                                                  //remember for sure

          System.Threading.Thread.Sleep(100);     //gives the program time to open it

          SendKeys.Send("{F11}");                 //F11 starts the slideshow

          System.Threading.Thread.Sleep(2000);    //waits for the slideshow to start

          SendKeys.SendWait(" ");                 //hits the spacebar to pause the
                                                  //slideshow
         }

        private void pictureBox2_Click(object sender, EventArgs e)
        {
         string input = "Pic2.jpg";
         Process newProc = Process.Start(input);
          System.Threading.Thread.Sleep(100);
          SendKeys.Send("{F11}");
          System.Threading.Thread.Sleep(2000);
          SendKeys.SendWait(" ");
        }

        private void pictureBox3_Click(object sender, EventArgs e)
        {
         string input = "Pic3.jpg";
         Process newProc = Process.Start(input);
          System.Threading.Thread.Sleep(100);
          SendKeys.Send("{F11}");
          System.Threading.Thread.Sleep(2000);
          SendKeys.SendWait(" ");
        }

        private void pictureBox4_Click(object sender, EventArgs e)
        {
         string input = "Pic4.jpg";
         Process newProc = Process.Start(input);
          System.Threading.Thread.Sleep(100);
          SendKeys.Send("{F11}");
          System.Threading.Thread.Sleep(2000);
          SendKeys.SendWait(" ");
        }

        private void pictureBox5_Click(object sender, EventArgs e)
        {
         string input = "Pic5.jpg";
         Process newProc = Process.Start(input);
          System.Threading.Thread.Sleep(100);
          SendKeys.Send("{F11}");
          System.Threading.Thread.Sleep(2000);
          SendKeys.SendWait(" ");
        }

        private void pictureBox6_Click(object sender, EventArgs e)
        {
         string input = "Pic6.jpg";
         Process newProc = Process.Start(input);
          System.Threading.Thread.Sleep(100);
          SendKeys.Send("{F11}");
          System.Threading.Thread.Sleep(2000);
          SendKeys.SendWait(" ");
        }

        private void pictureBox7_Click(object sender, EventArgs e)
        {
         string input = "Pic7.jpg";
         Process newProc = Process.Start(input);
          System.Threading.Thread.Sleep(100);
          SendKeys.Send("{F11}");
          System.Threading.Thread.Sleep(2000);
          SendKeys.SendWait(" ");
        }
    }
}


Sorry if this code is alittle rushed or something I am tired, but I thought you might be interested in this code, if you have any questions don't hesistate to ask i'll try and do my best to help you (I built this to present a photo assignment for a class, my way of doing something other then powerpoint)

Ange1ofD4rkness
Junior Poster
123 posts since May 2010
Reputation Points: 10
Solved Threads: 3
 

This question has already been solved

Post: Markdown Syntax: Formatting Help
You
View similar articles that have also been tagged: