473,545 Members | 721 Online
Bytes | Software Development & Data Engineering Community
+ 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 1527
Frinavale
9,735 Recognized Expert Moderator Expert
Seems pretty straightforward to me:

If myXMLFileIsVali d 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\Des ktop\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
@amirghaffarie13 62
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.ToBoole an(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
2941
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 resources was much simpler: you logged in with a userID and password, and when you were done you ended your session by logging out (or occasionally by...
1
2067
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 compiler seems to treat the char as an integer. The program prints out the decimal value of the char.
0
2589
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, arnm03, armo53, ardy53, arcc53, aryr53, arcd64, arid02 from NJIPD.ARLTNT2 WHERE arno01=13962 ORDER BY arno01 ASC, arcd01 ASC (one where clause)
2
3724
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 that uses If...Else logic to return the resultset. What I am finding perplexing is that the procedure works just fine when ran from some SQL...
7
2845
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 explain me what does the above statement mean? <script runat="server"> Class Clock
9
3099
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 be inserted into a standard web address in the table (the filed name is link) in ddw1 Example address ---
1
1402
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 (<=1 record per staff member per day) data from different legacy systems, populated by DTS. There is an 11th table that has staff data in which is...
0
1682
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 Panels represent a Master-Detail type relationship. I want a user to click a LinkButton in the first Panel and then for the 2nd Panel to be displayed...
1
1661
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 things incorrectly... I've got my database and imported my DBML to set up my data context. I've got a bunch of web methods to transport data back and...
0
7465
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7398
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7656
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
1
5325
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
4944
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3449
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
1
1878
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 we have to send another system
1
1013
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
701
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.