I cant figure out what is wrong i keep getting this an OIEception that says "{"The process cannot access the file because it is being used by another process."}

I am trying to move a file from a folder to another folder.
here is my code:
//storage of the all files
string[] folderContentNames = Directory.GetFiles(@"C:\Users\Jonah\Desktop\Test Pictures");
private void historyPictureBox_Click(object sender, EventArgs e)
destinationFile = @"C:\Users\Jonah\Desktop\Test Test";
File.Move(folderContentNames[1], destinationFile);
updateListBoxFileName();
updateImageBox();
each time I hit the bolded underlined part I get that error message.
if you need anything else just ask.
Thanks in advance,
Thor Orb

Hi Thor,
If you want to move a file from a folder to another folder, I think you could get the sourcePath and TargetPath. The code below shows a simple demo:
string[] folders = Directory.GetFiles(@"D:\Test\VSC#\01\WindowsFormsApp\WindowsFormsApp\Test");
string desFile =Path.Combine( @"D:\Test\VSC#\01\WindowsFormsApp\WindowsFormsApp\Test - Copy\"+Path.GetFileName(folders[1]));
File.Move(folders[1], desFile);
In addition, the link below might be useful to you:
# How to: Copy, Delete, and Move Files and Folders (C# Programming Guide)
>> The process cannot access the file because it is being used by another process
The message seemed that the file was opened in other process. Did you operate the file with other code?
I think you could check if the files and the folders were opened, and review your codes if they were used in other places.
If you have any further questions, please feel free to post in this forum.
Best Regards,
Edward
We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place. <br/> Click <a
href="http://support.microsoft.com/common/survey.aspx?showpage=1&scid=sw%3Ben%3B3559&theme=tech"> HERE</a> to participate the survey.
Ya, Thanks I figured about the path and destation. yes I am using the file in another area, the file is an image jpg and I am displaying it in a picture box. Now I have been doing a little research I see a command called Dispose() and this is suppose to
release the handle on the image, but I can seem to figure out have to use it correctly.
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Collections;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.IO;
namespace Scanned_Picture_Ogranizer
public partial class Form1 : Form
//storage of the all files
string[] folderContentNames = Directory.GetFiles(@"C:\Users\Jonah\Desktop\Scan Project Testing\Test Pictures", "*.jpg");
//List<string> folderContentList = folderContentNames.ToList();
private List<string> folderContentList = new List<string>();
Bitmap currentImage;
Bitmap placeHolder;
public Form1()
InitializeComponent();
convertingArrayToList();
startUpData();
string sourceFile = @"C:\Users\Jonah\OneDrive\My Programming Projects\Scanned Picture Organizer Project\Test Pictures";
string destinationFile = "";
private void moveButton_Click(object sender, EventArgs e)
private void startUpData()
//placeHolder = new Bitmap(folderContentList[0]);
//currentImage = (Bitmap)placeHolder.Clone();
// Image loadImage = new Bitmap(pictureClones[0]);
// currentFilePictureBox.Image = loadImage;
int numberOfFilesLeft = folderContentNames.Length;
foreach (string name in folderContentNames)
fileNamesListBox.Items.Add(name);
fileNameTextBox.Text = folderContentNames[0];
numberOfFilesLeftTextBox.Text = numberOfFilesLeft.ToString();
///loadImage.Dispose();
//FileStream currentImage = new FileStream(folderContentList[0], FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
private void convertingArrayToList()
foreach (string listName in folderContentNames)
folderContentList.Add(listName);
private void selectingImageFromListBox()
private void updateImageBox()
Bitmap currentImage = new Bitmap(folderContentList[0]);
currentFilePictureBox.Image = currentImage;
currentImage.Dispose();
private void updateListBoxFileName()
fileNamesListBox.Items.RemoveAt(0);
fileNameTextBox.Text = folderContentList[0];
// numberOfFilesLeftTextBox.Text = numberOfFilesLeft.ToString();
private void historyPictureBox_Click(object sender, EventArgs e)
destinationFile = @"C:\Users\Jonah\Desktop\Scan Project Testing\Test Test\";
File.Move(folderContentList[0], destinationFile + System.IO.Path.GetFileName(folderContentList[0]));
folderContentList.RemoveAt(0);
updateImageBox();
updateListBoxFileName();
when I first start the program the first picture displays, but when I trigger historyPictureBox_Click(), it does that error again. Another things is that I already looked at that link and it didn't help.
I just super confused, I would like your help on this.
Thanks,
Thor Orb

Similar Messages

  • I keep getting this error message that says "There is a problem with this windows intaller packaage.a program required for this install to complete could not be run.contact ur support personnel or package vendor" what does it mean?

    I keep getting this error message that says "There is a problem with this windows intaller packaage.a program required for this install to complete could not be run.contact ur support personnel or package vendor" what does it mean? and how do i fix it?

    Try the following user tip:
    "There is a problem with this Windows Installer package ..." error messages when installing iTunes for Windows

  • Calling all java gurus - i cant figure out what is wrong with my code

    please can someone see why a null pointer exception is being thrown and how do i fix it?
    my current code which throws the null pointer is as below - the key issues that i need some java expert to tell me about is
    1. is the usage of resultSet ok in the way i'm doing it , i'm not able to look at the code in debug mode as don't have an IDE and don't know how to do a log4j setup. - i tried doing an out.println("Got........"); but servlet keeps on forwarding the request object to results.jsp even when i comment out the code. and recomplie and restart tomcat 4.1.
    2. is the way i'm declaring the List object and the adding stuff to bean and then stuffing bean into list ok?
    3. why is the List object null? although i know the query works fine - and that using the below original code where only one row of data was being retrieved and set into bean worked fine.
    current code with problem in the List object:
    package com.bt.ros;
    import java.util.*;
    import java.io.*;
    import java.net.*;
    import javax.servlet.*;
    import javax.servlet.http.*;
    import java.sql.*;
    import javax.sql.*;
    import javax.naming.InitialContext;
    import javax.naming.Context;
    import javax.naming.NamingException;
    * This class is a servlet that searches for a Finder Aid.
    * @author
    public class FinderAidsSearchS extends HttpServlet {
       * This is the static initializer,
       * executed the first time this class is referred to.
       * It makes sure the JDBC pool driver is loaded.
       * This method examines an HTTP request and searches for the
       * specified Finder Aid record in the database. It then redirects
       * the response to the <tt>Results.jsp</tt> JSP page.
      public void service(HttpServletRequest req, HttpServletResponse res)
           throws IOException
        HttpSession session = req.getSession(true);
    //res.setContentType("text/html");
    //PrintWriter out = res.getWriter( );
    //out.println("<HTML>");
    //out.println("<HEAD>");
    //out.println("<TITLE>");
    //out.println("A Servlet Example");
        String year   = req.getParameter("Year");
        String year_range      = req.getParameter("Year_Range");
        String county          = req.getParameter("County");
        Connection conn = null;
        try {
    //example code from tomcatmanual
    Context initContext = new InitialContext();
    Context envContext  = (Context)initContext.lookup("java:/comp/env");
    DataSource ds = (DataSource)envContext.lookup("jdbc/rosDS");
    //Connection
    conn = ds.getConnection();
              Statement stmt = conn.createStatement();
          String select = "select * from abridgment where " +
                          "(a_county = '" + county +
                          "' AND a_year_date = " + year +
    out.println("<DEBUG> <select> the select staement is : " + select);
          stmt.execute(select);
          ResultSet resultSet = stmt.getResultSet();
         Results abridgeresults = new Results();
         abridgeresults.setName("NaeemColl");
         Abridgment varabridgment = null;
          int nRows = 0;
          while(resultSet.next()){
            nRows++;
               varabridgment = new Abridgment();
           varabridgment.seta_county(county);
          varabridgment.seta_year_date(Integer.parseInt(year));
            varabridgment.seta_sub_year_volume(resultSet.getInt("a_sub_year_volume"));
           // out.println("varabridgment - attributes are:");
              //out.println("varabridgment - attributes are:" +varabridgment.geta_sub_year_volume());
              //out.println("varabridgment - attributes are:"+resultSet.getInt("a_sub_year_volume"));
              varabridgment.seta_page_id(resultSet.getString("a_page_id"));
            varabridgment.seta_month_date(resultSet.getInt("a_month_date"));
            varabridgment.seta_day_date(resultSet.getInt("a_day_date"));
            varabridgment.seta_year_sequence(resultSet.getLong("a_year_sequence"));
            varabridgment.seta_day_sequence(resultSet.getLong("a_day_sequence"));
            varabridgment.seta_year_volume(resultSet.getInt("a_year_volume"));
            varabridgment.seta_volume_id(resultSet.getString("a_volume_id"));
            varabridgment.seta_summary(resultSet.getString("a_summary"));
            varabridgment.seta_batch_id(resultSet.getLong("a_batch_id"));
            varabridgment.seta_image_id(resultSet.getLong("a_image_id"));
              abridgeresults.addAbridgment(varabridgment);
              //trying to use vector construct
          req.setAttribute("results",abridgeresults);
          //session.setAttribute("results", abridgeresults);
          stmt.close();
          conn.close();
    //out.println("</BODY>");
    //out.println("</HTML>");
    //      String sURL = res.encodeRedirectURL("/rossearch/results.jsp");
            try{
    //TEMPCOMM        res.sendRedirect(sURL);
    req.getRequestDispatcher("/rossearch/results.jsp").forward(req, res);
    //TEMPCODE
    //out.println("</BODY>");
    //out.println("</HTML>");
          catch(Exception e){
            System.err.println("Exception: FinderAidsSearchS.service: " + e);
        catch (Exception e) {
          System.err.println("Exception: FinderAidsSearchS.service: " + e);
    original code that worked fine - for one test row retrieved by query
      public void service(HttpServletRequest req, HttpServletResponse res)
           throws IOException
        HttpSession session = req.getSession(true);
    res.setContentType("text/html");
    PrintWriter out = res.getWriter( );
    out.println("<HTML>");
    out.println("<HEAD>");
    out.println("<TITLE>");
    out.println("A Servlet Example");
    out.println("</TITLE>");
    out.println("</HEAD>");
    out.println("<BODY>");
    out.println("Using servlets");
       // if (! checkParams(req, res))
       //      return;
        String year   = req.getParameter("Year");
        String year_range      = req.getParameter("Year_Range");
        String county          = req.getParameter("County");
        Connection conn = null;
        try {
    //example code from tomcatmanual
    Context initContext = new InitialContext();
    Context envContext  = (Context)initContext.lookup("java:/comp/env");
    DataSource ds = (DataSource)envContext.lookup("jdbc/rosDS");
    //Connection
    conn = ds.getConnection();
          Statement stmt = conn.createStatement();
          String select = "select * from abridgment where " +
                          "(a_county = '" + county +
                          "' AND a_year_date = " + year +
    out.println("<DEBUG> <select> the select staement is : " + select);
          stmt.execute(select);
          ResultSet resultSet = stmt.getResultSet();
          Abridgment abridgment = new Abridgment();
          abridgment.seta_county(county);
          abridgment.seta_year_date(Integer.parseInt(year));
        //  abridgment.a_sub_year_volume        = Long.parseLong(c_phone);
          if (resultSet.next()){
            abridgment.seta_sub_year_volume(resultSet.getInt("a_sub_year_volume"));
            abridgment.seta_page_id(resultSet.getString("a_page_id"));
            abridgment.seta_month_date(resultSet.getInt("a_month_date"));
            abridgment.seta_day_date(resultSet.getInt("a_day_date"));
            abridgment.seta_year_sequence(resultSet.getLong("a_year_sequence"));
            abridgment.seta_day_sequence(resultSet.getLong("a_day_sequence"));
            abridgment.seta_year_volume(resultSet.getInt("a_year_volume"));
            abridgment.seta_volume_id(resultSet.getString("a_volume_id"));
            abridgment.seta_summary(resultSet.getString("a_summary"));
            abridgment.seta_batch_id(resultSet.getLong("a_batch_id"));
            abridgment.seta_image_id(resultSet.getLong("a_image_id"));
            session.setAttribute("isNewAbridgment", new Boolean(false));
          else{
            session.setAttribute("isNewAbridgment", new Boolean(true));
            out.println("<DEBUG> <AbridgmentSearchS-service> Abridgment not found: " + abridgment);
          session.setAttribute("abridgment", abridgment);
          stmt.close();
          conn.close();
    out.println("</BODY>");
    out.println("</HTML>");
          String sURL = res.encodeRedirectURL("/rossearch/results.jsp");
              try{
            res.sendRedirect(sURL);
          catch(Exception e){
            System.err.println("Exception: FinderAidsSearchS.service: " + e);
        catch (Exception e) {
          System.err.println("Exception: FinderAidsSearchS.service: " + e);
    exception being thrown is:
    2005-11-07 02:45:20 StandardWrapperValve[jsp]: Servlet.service() for servlet jsp threw exception
    org.apache.jasper.JasperException
         at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:254)
         at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:295)
         at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:241)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
         at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:247)
         at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:193)
         at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:256)
         at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
         at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
         at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
         at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
         at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
         at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
         at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
         at org.apache.catalina.core.StandardContext.invoke(StandardContext.java:2415)
         at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:180)
         at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
         at org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatcherValve.java:171)
         at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)
         at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:172)
         at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)
         at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
         at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
         at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:174)
         at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
         at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
         at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
         at org.apache.coyote.tomcat4.CoyoteAdapter.service(CoyoteAdapter.java:223)
         at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:594)
         at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:392)
         at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:565)
         at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:619)
         at java.lang.Thread.run(Thread.java:536)
    ----- Root Cause -----
    java.lang.NullPointerException
         at org.apache.jsp.results_jsp._jspService(results_jsp.java:95)
         at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:137)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
         at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:210)
    ......etc..
    the problem line in the results_jsp.java is:
    for (int i = 0; i < myAbridgments.size(); i++) in a scriptlet in the jsp to retrieve the List of beans and go through each one as follows:
    <% List myAbridgments = (List) request.getAttribute("results");
    for (int i = 0; i < myAbridgments.size(); i++) {
                    abridgment = (Abridgment) myAbridgments.get(i);
    %>ok then all wanabe java experts lets see who is the first and best at resolving this one!
    i have 10 points on offer - and a HUGE AMOUNT of graditude and appreciation for any one who can help me resolve this - Thanks.

    Check replies here
    http://forum.java.sun.com/thread.jspa?threadID=680127

  • I am trying to sync and i get "apple mobile device service not started yet".  i have sunk before to this computer and cant figure out what is wrong?  my iphone does not show in the devices on itunes.

    i have the same problem trying to synch my ipod 4 touch.

    http://support.apple.com/kb/TS1567
    Regards.

  • I have a samsung intensity ll.How do i get rid of a small box with AA off of my main screen?Cant figure out what setting it is.

    How do i get rid of a small box with AA in it on my main screen? cant figure out what setting it is on my samsung intensity ll ?

    Good deal      (the AA stands for Auto Answer, by the way; and I like your avatar  )

  • I cant figure out what my user icon is a picture of!!!

    i just reinstalled tiger and i cant figure out what my new icon is a picture of. Any suggestions?
    http://i112.photobucket.com/albums/n183/xxxSinkEmFastxxx/Picture2-3.png

    All user pictures are located in /Library/User Pictures/. Figuring out which is which, is left as an exercise. More than likely, a flower or nature thingy. They'll all open in Preview.

  • Trouble with calculating fields. Can't select (check) fields. Also can't figure out what's wrong with a division field (percent) that I created. Keep getting the pop up that format of the field doesn't allow blah blah blah... Help!

    Trouble with calculating fields. Can't select (check) fields. Also can't figure out what's wrong with a division field (percent) that I created. Keep getting the pop up that format of the field doesn't allow blah blah blah... Help!

    1. Use the mouse to select the field and then press the space bar.
    2. A null string is the same as zero. What is the result for division by zero?

  • HT1414 In updating my iTunes,I got a message "Service Apple Mobile Device failed to start. verify that you have sufficent priviliges to start system services". Cant figure out what to do

    In updating my iTunes,I got a message "Service Apple Mobile Device failed to start. verify that you have sufficent priviliges to start system services". Cant figure out what to do

    So many people are having this problem! Doehunter's instructions here worked for me!  Hope this helps. https://discussions.apple.com/message/23824640#23824640

  • I connected to itunes and it says i have 2.11 GB of space taken up under OTHER , i cant figure out what is taking up so much space can anyone help?

    i connected to itunes and it says i have 2.11 GB of space taken up under OTHER , i cant figure out what is taking up so much space can anyone help?

    I believe the new IOS 8 system takes up 1.3 Gb on it's own.   Then plus anything else you may have loaded.

  • My macbook pro will not play a video without pausing every 11 seconds. PLEASE help me figure out what is wrong. very frustrating

    my macbook pro will not play a video without pausing every 11 seconds. PLEASE help me figure out what is wrong. very frustrating. I have already tried restarting

    buckmacie,
    has the video been completely downloaded onto your MacBook Pro when you start to play it? Or are you playing it while it downloads, AKA streaming it?

  • Hi. I cant figure out, what I will get in the creative cloud.

    Hi. I cant figure out, what I will get in the creative cloud. ?? Do I get it all ?? if not wich programs are in it. ? I hope, i can get an answar fast :-)

    Cloud Plans https://creative.adobe.com/plans
    -Special Photography Plan includes Photoshop & Lightroom & Bridge & Mobile Lightroom
    -Special Photography Plan includes 2Gig of Cloud storage (not the 20Gig of the full plan)
    -http://helpx.adobe.com/creative-cloud/faq/mobileapps.html
    -http://helpx.adobe.com/photoshop/kb/differences-photoshop-creative-cloud-photography.html
    -and subscription terms http://www.adobe.com/misc/subscription_terms.html
    -what is in the entire Cloud http://www.adobe.com/creativecloud/catalog/desktop.html
    -http://www.adobe.com/products/catalog/mobile._sl_id-contentfilter_sl_catalog_sl_mobiledevi ces.html

  • HT201304 my i phone says its disabled until i die just jokes but for a long time and i cant figure out what to do its my phone

    my i phone says its disabled until i die just jokes but for a long time and i cant figure out what to do its my phone

    Follow the instructions in this support document for a disabled iPhone. iOS: Forgot passcode or device disabled

  • HT5622 I cant figure out how to authorize my office computer to download songs that I have purchased. A message saying I cant do it, but gives me no link to make it happen. Frustrating.Can someone help?

    I cant figure out how to authorize my office computer to download songs that I have purchased. A message saying I cant do it, but gives me no link to make it happen. Frustrating.Can someone help?

    If you're running iTunes 11 and you don't see the menus, press Control-B or go to the small icon with the arrow at the extreme upper left and select "Show Menu Bar":
    Apple for some inexplicable reason elected to hide the menus by default in the Windows version of iTunes 11.
    I doubt that this will address a download problem, though. You'll need to provide more details about that; what device you're attempting the download on, the exact error message, and other such pertinent information.
    Regards.

  • Have not used Itunes in a while and I cant access Itunes Store with out downloaded new version but I keep getting error message with download. Can I just access the Istore without downloading new version?

    Have not used Itunes in a while and I cant access Itunes Store with out downloaded new version but I keep getting error message with download. Can I just access the Istore without downloading new version?

    downloaded new version but I keep getting error message with download.
    What does the error message say, andrea? (Precise text, please.)

  • I downloaded an album and one single song just fine and then bought a second song and I keep getting an error message that says, You don't have enough access priviledges.  What can I do to download this song?

    I downloaded an album and one single that I purchased just fine and then purchases another single and I keep getting an error message that says, You don't have enough access priviledges.  What can I do to get this song?  I am just going to have to ask for a refund and forget it?

    What version of iPhoto do you have installed?  Is if one of the versions shown as not compatible in this screenshot?
    If it is then go to the App Store and download iPhoto 9.5.  It will be free if you have an iPhoto 9 or later verson currently.
    OT

Maybe you are looking for

  • Can you sign a ipa created with adobe's DPS with a Apple's Enterprise developers

    Now we have an app that we do not want to go through the apple store for approval and keep it in-house. And the Adobe's enterprise is more then what any here can afford. I read somewhere that "Apple Enterprise customers can sign an app without the UD

  • How to change number of records displayed in Web service: Query_view_data

    Hi experts I´m using webservice Query_view_data to fill a Xcelsius model with data. The Bex Query contains appr. 300 records but the webservice returns only 50 records. When I test it it says "displaying 50 of 312 records". When I tried ABAP FM RRW3_

  • Why does my iPhone 5 keep telling me that storage is almost full?

    Since I upgraded my iPhone 5 to iOS 7 it has been acting strange. I keep getting messages telling me that the storage is almost full yet when I check there is over 358mb of free space. I have tried restoring my iPhone but I still keep getting these e

  • Web based Game

    Hi Friends. I want to design a web based game. There is a server and two clients. Each client is a player and the server will handle the collaboration between them. I am using Netbeans and jsp. First client one will type the url of server and gets co

  • Why Airport Utility not pick up AirPort Extreme?

    Suddenly AirPort Utility on MacPro not picking up AirPort Extreme for wireless.  Other Macs in house connecting just fine.


HashFlare