473,480 Members | 4,985 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Putting data in different folders depending upon condition using web services

121 New Member
hi all,
what i am trying to do is i have three folders
1) sentto
2) error
3) sent

i am using web services in which we give the name of XML file ( which is in sentto folder. when the name is given , my web service validates it with a schema and now according to result(which is validated or not-validated). i want to shift that XML file to error folder( if not validated) or sent folder ( if validated) . when this file is shifted the original file should be deleted.

I have created a web-service which performs this action, now how to put this XML file into error or sent folder depending on condition.

any help wil be appreciated.

Thanks in advance
Jan 26 '09 #1
9 1522
Frinavale
9,735 Recognized Expert Moderator Expert
Seems pretty straightforward to me:

If myXMLFileIsValid Then
--> Move the File to the Sent Folder
Else
--> Move the File to the Error Folder
End If

To move a file use the System.IO.File.Move() method.
Jan 26 '09 #2
jay123
121 New Member
thanks Frinavale,
that was a solution but i am still getting an error as

The target file "C:\abc\def\Desktop\XML\Sent" is a directory, not a file.

as i want to save my Xml file to folder sent.

any suggestions?

below is the file.copy command i have used

Expand|Select|Wrap|Line Numbers
  1. File.Copy("Sendto\\" + FileName + ".xml", @"C:\abc\def\Desktop\XML\sent", Convert.ToBoolean(8));
Jan 27 '09 #3
amirghaffarie1362
19 New Member
use
File.Copy( server.mathpad("locations")
Jan 27 '09 #4
Frinavale
9,735 Recognized Expert Moderator Expert
@amirghaffarie1362
I think you meant to say Server.MapPath("locations")


Try the following:
Expand|Select|Wrap|Line Numbers
  1. File.Copy("Sendto\\" + FileName + ".xml", @"C:\abc\def\Desktop\XML\sent\"+ FileName + ".xml", Convert.ToBoolean(8));
Jan 27 '09 #5
Curtis Rutland
3,256 Recognized Expert Specialist
Well, here's an easy way to do this:
Expand|Select|Wrap|Line Numbers
  1. string senttoDir = Server.MapPath("~/sentto/"); //this should be the relative path to your sentto dir
  2. string sentDir = Server.MapPath("~/sent/");//this should be the relative path to your sent dir
  3. FileInfo file = new FileInfo(senttoDir + FileName); //assuming you have declared FileName somewhere else
  4. file.MoveTo(sentDir + FileName);
FileInfo and DirectoryInfo are your best friends for file and directory operations. Both are part of the System.IO namespace.

EDIT:
I'm curious, why are you using
Expand|Select|Wrap|Line Numbers
  1. Convert.ToBoolean(8)
? Shouldn't that just be true?
Jan 27 '09 #6
jay123
121 New Member
that
Expand|Select|Wrap|Line Numbers
  1. convert.boolean(8) 
is if that directory doesnt exist , it will create it first and then put this file in it
Jan 27 '09 #7
Curtis Rutland
3,256 Recognized Expert Specialist
I understand what that particular argument does, but Convert.ToBoolean(8) is equal to true so why not just use true?

Anyway, try my example, or Frinny's and let us know what happens.

My example is more portable, so if you ever move it off your desktop and onto a web server, you won't have to manually change the paths.
Jan 27 '09 #8
jay123
121 New Member
actually i am writing console application , so the path will always be in setting folder. actually initially i was using only 8 and i was getting an error of can't convert int to bool so i just added convert.bool to it.
Jan 27 '09 #9
Curtis Rutland
3,256 Recognized Expert Specialist
OK, I thought this was ASP.NET...so Server.MapPath won't work.

Here's my sample revised for desktop:
Expand|Select|Wrap|Line Numbers
  1. //make these global variables
  2. string senttoDir = @"C:\abc\def\Desktop\XML\sentto";
  3. string sentDir = @"C:\abc\def\Desktop\XML\sent";
  4.  
  5. //put this where you want to do the move
  6. FileInfo file = new FileInfo(senttoDir + FileName); //assuming you have declared FileName somewhere else
  7. file.MoveTo(sentDir + FileName);
As to the bool thing, I don't know why you think you have to use 8. Bools can only be true/false, so just use true.
Jan 27 '09 #10

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

Similar topics

8
2934
by: Frnak McKenney | last post by:
Back when computer dinosaurs roamed the earth and the precursors to today's Internet were tiny flocks of TDMs living symbiotically with the silicon giants, tracking access to data processing...
1
2057
by: John Smith | last post by:
How do I use two different data types with a conditional operator ? I want to cout either a character or an integer depending on a certain condition. cout << ((IsThisTrue? char:integer) The...
0
2582
by: xixi | last post by:
hi, we are using db2 udb v8.1 on win 64 bit with fp3 with type 4 db2jcc.jar driver. when i execute this query , select id, arno01, arcd01, arno16, artx01, armo09, ardy09, arcc09, aryr09,...
2
3722
by: mr_mach7 | last post by:
I have a situation in which I want to dynamically build a SQL statement based upon criteria. The statement would contain different fields depending upon the criteria. I created a Stored Procedure...
7
2840
by: Arpan | last post by:
The .NET Framework 2.0 documentation states that An Object variable always holds a pointer to the data, never the data itself. Now w.r.t. the following ASP.NET code snippet, can someone please...
9
3094
by: sellcraig | last post by:
Microsoft access 2 tables table "data main" contains a field called "code" table "ddw1" is created from a make table query of "data main" Goal- the data in "code" field in needs to...
1
1396
by: C4rtm4N | last post by:
I'm about to embark on re-writing a database & bespoke web reporting application for our call centre & would like a little advice please. Currently the database has 10 tables containing summaried...
0
1675
by: db007 | last post by:
I have a problem at the moment with a web project. I have two Panels within an UpdatePanel on an aspx page (using Masterpages). I'm using ASP.Net 2.0 with an AJAX enabled website. The two...
1
1655
balabaster
by: balabaster | last post by:
Does anyone have experience integrating LINQ into SOA architecture. I've spent all night trawling through documents and books regarding this and I've come to the conclusion that I'm going about...
0
6905
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
1
6736
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
5331
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
4478
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
2994
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
2980
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1299
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
561
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
178
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.