Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

How to call the code?

Posted on 2014-07-29
9
Medium Priority
?
176 Views
Last Modified: 2014-07-29
I have a class file in my solution GetFile.cs
In here is a function called CopyFile()

In order to test CopyFile() I added a webform to the solution and in the page_load event in the code behind I am trying to call CopyFile() but no matter how I try intellisense is not offering it up.
I have tried CopyFile() and I have tried creating a new instance of GetFile as below but still I can't "reach" it

 public partial class _default : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            GetFile theFile = new GetFile();

Open in new window


Here is CopyFile()

namespace HubbleDocs
{
    public class GetFile
    {

        
        public void CopyFile()
        {
...
}

Open in new window

0
Comment
Question by:QPR
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 4
9 Comments
 
LVL 75

Expert Comment

by:käµfm³d 👽
ID: 40228210
Add a using statement to the top of your _default class:

using HubbleDocs;

Open in new window

0
 
LVL 29

Author Comment

by:QPR
ID: 40228221
Sorry I should have posted the whole of default.aspx.cs as I already have that using statement

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using HubbleDocs;

namespace HubbleDocs
{
    public partial class _default : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            GetFile theFile = new GetFile();
            
        }
    }
}

Open in new window

0
 
LVL 75

Expert Comment

by:käµfm³d 👽
ID: 40228227
Is GetFile defined with the same assembly (i.e. project)?
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
LVL 29

Author Comment

by:QPR
ID: 40228232
Yep, solution/project is called HubbleDocs which consists of GetFile.cs and default.aspx/cs (and a web service reference)
0
 
LVL 29

Author Comment

by:QPR
ID: 40228237
solution files
0
 
LVL 75

Expert Comment

by:käµfm³d 👽
ID: 40228254
Is it possible to post the entire GetFile definition?
0
 
LVL 29

Author Comment

by:QPR
ID: 40228258
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Net;
using System.IO;


namespace HubbleDocs
{
    public class GetFile
    {

        
        public void CopyFile()
        {
            string webUrl = "http://xxx";
            FileCopy.Copy copyService = new FileCopy.Copy();
            copyService.Url = webUrl +"/_vti_bin/copy.asmx";
            NetworkCredential m_credentials = new NetworkCredential("x", "x", "x");
                 copyService.Credentials = m_credentials;

            //Source and Destination Document URLs
             string sourceUrl = "http://xxx/Documents/Sample.docx";
             string destinationUrl = "C:\\Documents\\Sample.doc";

            //Variables for Reading metadata’s of a document
             FileCopy.FieldInformation fieldInfo = new FileCopy.FieldInformation();
             FileCopy.FieldInformation[] fieldInfoArray = { fieldInfo };
             FileCopy.CopyResult cResult1 = new FileCopy.CopyResult();
             FileCopy.CopyResult cResult2 = new FileCopy.CopyResult();
             FileCopy.CopyResult[] cResultArray = { cResult1, cResult2 };

        

            //Receive a Document Contents  into Byte array (filecontents)
             byte[] fileContent; // no need to initialize the GetItem takes care of that.
             copyService.GetItem(sourceUrl, out fieldInfoArray, out fileContent);

            //Create a new file and write contents to that document
             FileStream fStream = new FileStream(destinationUrl, FileMode.Create, FileAccess.ReadWrite);
            fStream.Write(fileContent, 0, fileContent.Length);
            fStream.Close();
        }
    }
}

Open in new window

0
 
LVL 75

Accepted Solution

by:
käµfm³d   👽 earned 2000 total points
ID: 40228271
Based on what you've posted, I don't see anything wrong. You should only have to invoke against the instance.

e.g.

GetFile theFile = new GetFile();

theFile.CopyFile();

Open in new window

0
 
LVL 29

Author Comment

by:QPR
ID: 40228276
and now that I type it again I see it and it works!
So either my tired eyes didn't see it in the intellisense or the intellisense hadn't refreshed.
Oh well - all good now :)
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

User art_snob (http://www.experts-exchange.com/M_6114203.html) encountered strange behavior of Android Web browser on his Mobile Web site. It took a while to find the true cause. It happens so, that the Android Web browser (at least up to OS ver. 2.…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…
In response to a need for security and privacy, and to continue fostering an environment members can turn to for support, solutions, and education, Experts Exchange has created anonymous question capabilities. This new feature is available to our Pr…

721 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question