ASP.NET - Copying An Image from a folder to another using Web services

Asked By nikita kumar
06-Sep-10 12:57 AM
Hi,
I am new to Web Services.Can anybody help me how to copy an image file from a folder into another using web services ...
I will be really greatfull to those who help me....
Thanks..
  Anand Malli replied to nikita kumar
06-Sep-10 03:36 AM
HI nikita,

Web service is nothing but and consumable application,what you do with web site can web service do right,but we are dealing with files on the server so you will need to make sure that you give enough rights to your those directories otherwise you will not be able to move your files,i have created web service just see the code below

using System;
using System.Web.Services;
using System.IO;
 
[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
// To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line.
// [System.Web.Script.Services.ScriptService]
public class Service : System.Web.Services.WebService
{
  public Service () {
 
    //Uncomment the following line if using designed components
    //InitializeComponent();
  }
 
  [WebMethod]
  public string HelloWorld() {
    return "Hello World";
  }
  [WebMethod]
  public bool MoveImage()
  {
    bool isMoved = true;
    try
    {
      File.Move("C:\\Folder1\\myfamily.JPG", "C:\\Folder2\\myfamily.JPG");
    }
    catch (Exception ex)
    {
      isMoved = false;
    }
    return isMoved;
  }
}

just see the move function,i have created two folders Folder1 and Folder2,initially i have drop one file in Folder1 and moving to Folder2 with our function,you can see whole process on below snapshot,here i have not added reference of this to my page,but i have invoked it directly,you can do it by add reference


just ping me with your feedback

thanxs
  nikita kumar replied to Anand Malli
06-Sep-10 04:55 AM
Your code rocks....Thanks a lot for ur help.... u made my day...
  Anand Malli replied to nikita kumar
06-Sep-10 04:56 AM
Hey niki...thxs for such awesome reply....
  nikita kumar replied to Anand Malli
07-Sep-10 01:36 AM
Once again thanks for ur help...Can you just help me out telling me how it would work if the source and destination are in different servers....


Thanks..
  Anand Malli replied to nikita kumar
07-Sep-10 01:41 AM
Hi Niki,

May be you can look for some WCF application which would be hosted on different machine and when called can just take the file from one computer to other computer...by usnig net.tcp protocol i think that would give you good start for this scenario

THXS
  nikita kumar replied to Anand Malli
07-Sep-10 02:57 AM
Hi,
Thanks again for the help but I have not worked in WCF..do u have any idea if can be done using web services or not...do we have to use Streams in that case?
Create New Account
help
YearBuilt> <Bedrooms> 2< / Bedrooms> <Bathrooms> 2< / Bathrooms> <Features / > <Highlights / > < / Details> <Media> <Item id = "9580351" mimeType = "image / jpeg" medium = "image" caption = "View of one of the bedrooms!"> <Url style = "Gallery"> http: / / media.point2.com / p2a com / p2a / listing / 7c33 / a6dd / 7f6f / 144c1e3b73e2a67e71e8 / w64h48.jpg< / Url> < / Item> <Item id = "9580352" mimeType = "image / jpeg" medium = "image" caption = "Relax in the living room and take in the incredible views!"> <Url style = "Gallery com / p2a / listing / a0e5 / 2702 / 685e / 8b7fd1fb35da34b1e966 / w64h48.jpg< / Url> < / Item> <Item id = "9580353" mimeType = "image / jpeg" medium = "image" caption = "Renovated bathrooms. . ."> <Url style = "Gallery"> http: / / media.point2.com / p2a / listing / b779 / 1108 / c524 com / p2a / listing / b779 / 1108 / c524 / dd51cfb96d4ffaa8b261 / w64h48.jpg< / Url> < / Item> <Item id = "9580354" mimeType = "image / jpeg" medium = "image" caption = "Entertain friends in the living space in front of breathtaking views!"> <Url style = "Gallery
Net hi friends Any one send frequently asked Important questions in C# .Net, ADO .Net, Asp .Net and Sql Server. . . . . . . . tx in Advance. . . . . . Hi, Find this. . (B)What is an IL? (B I) what is the difference between Convert.toString and .toString () method? (A) What is Native Image Generator (Ngen.exe)? (A) If we have two version of same assembly in GAC how How can we know a state of a thread? (A) What is use of Interlocked class ? (A) What is a monitor object? (A) What are wait handles? (A) What is ManualResetEvent and Webservices (B)What is an application domain? (B) What is .NET Remoting? (B) Which class does the remote object has to inherit? (I) what are two different types of remote services? (B) Which attribute is used in order that the method can be used as WebService? (A) What are the steps to create a web service and consume it? (A) Do webservice have state? Chapter 5: Caching Concepts (B) What is an application object? (I) what is A) What is scavenging? (B) What are different types of caching using cache object of ASP.NET? (B) How can you cache different version of same page using ASP.NET cache
cannot be used with indexers, destructors, or types. In C#, the static keyword indicates a class variable. In VB, the equivalent keyword is Shared. Its scoped to the class in which it occurs. Example a. Static int var / / in c#.net b. static void in Sql server as var_name int How do you separate business logic while creating an ASP.NET application? There are two level of asp.net debugging 1. Page level debugging For this we have to edit the page level debugging The control itself will take care of the date display How can you deploy an asp.net application ? You can deploy an ASP.NET Web application using any one of the following
Migration from ASP to ASP.net How to convert ASP site to ASP.NET site using C# http: / / www.asp.net / downloads / archived-v11 / migration-assistants / asp-to-aspnet hi, ASP.NET framework is very much different from unstrucured ASP and there is no correct way to