Create Folder() Showing "<Result/>".But Folder are not getting created on Sharepoint - c#

I would like to create a folder in Sharepoint 2007 with C# using DWS Web Service.
Code:
dwsFolder.CreateFolder(#"Test_FormLib/myNewFolder");
If I use the program for the first time, I get the message:
<Result/>
No error. The second time I get the message:
<Error ID="13">AlreadyExists</Error>
But I do not see the folder on my website.
What am I doing wrong?

In another clown product from Microsoft, I just spend 4 hours on this exact problem. CreateFolder only works properly for document libraries, not form libraries. If you're trying to write to a form library, your documents are going to show up in another folder. For me, they were showing up in 'shared documents', even though I was specifying to create a folder under 'test'.

Take a look at documentation: Dws.CreateFolder Method (Document Workspace):
The following code example shows the use of the CreateFolder method to create a new subfolder in the default document library of the site. The absolute URL of the new folder is "http://server_name/sites/user_name/workspace_name/Shared Documents/folder_name".
So, you must check if you're using correct site address, under authenticated user_name.

Edit your web refrence config to include the proper path to your application.
Your config will look like this:
http://someserver/_vti_bin/Dws.asmx
Change it to
http://someserver/sub1/sub2/_vti_bin/Dws.asmx
dwsFolder.CreateFolder("Shared Documents/myNewFolder");

Related

How do I set the path to a file I am trying to open to be opened while hosted instead of depending on localhost directories wtih ASP.net?

I'm building a website that handles 2 files (simple ones like .txt) and I'm struggling to see how I can write the path in a way that it works when eventually I host the website.
Currently, I'm using this line of code just to make it work while I am working around it:
File.ReadAllLines(#"C:\Users\pinky\source\repos\PAP\PAP\files\filename.txt");
But when I try to change it for the following bit of code:
File.ReadAllLines("/files/filename.txt");
It stops working. And the strange thing is, it only stops working for the specific page I changed the path of the files.
If I try to debug it, it gives an error 404 and asks me if I have the path of the page right (which it is). What can I do to change this?
Ok, so, in your web site, you have the root, and then some folders.
And we assume that files is one of those folders.
Lesson #1:
When a user (or you) wants to use a URL, then of course URL's are
www.mywebsite/Files/dogs.png
So, keep in mind that say in HTML markup, a src etc. Then a path name is always assumed to be from the root of your site onwards.
However, despite the above CODE BEHIND still will ALWAYS STILL use a valid windows FULL PATHNAME to the file.
So, you use a built in function called server.MapPath
MapPath will take the web based url, and convert to a full internal windows path name.
So, your code would be like this:
string strIntenalFileName = Server.MapPath("/files/data.txt");
string MyText = File.ReadAllText(strIntenalFileName);
TextBox1.Text = MyText;
So just keep in mind that say we want to set a image control to have a picture from above.
Well, then we do this:
Image1.ImageUrl = "/files/dogs.png";
But, if you need in code behind to read the file, then we have to put above expression though Server.MapPath() to translate for code behind.
So, just remember WHEN dealing with web controls, HTML markup, the of course the URL and path name is web based. But, for code behind to directly interface and use the file, then code behind needs that "plane jane" and full legal windows path name.
So, for your example, wrap the string in Server.MapPath(" your web based path goes here").
you in effect can't really know the root path name of the web hosting server, but with above, you really don't care.
Often however, one does get "messed" up. Since for the above image, I shoved in the web based url for SCR. But, if I was to read the picture and say stream the picture bytes to the web control, then I would of course first convert/get a full windows path name.
The above is not really all that confusing, but keeping this "web url", "web markup" and that of direct file use in code behind is still a VERY good concept to keep alive in your mind when dealing with files.
Now, the above is a simple tip - but one that I wish was hammered home to me.
So:
web expresions, markup = web path name from web root.
code behind:
Still always MUST be a full plane jane windows file name!
So, in your case, to get the text file, we could (and you should try this), is type in this:

Not able to Convert .dwg to .pdf using .Net and True View (AcCtrl)

What I am trying to do is:
I have a Asp Mvc website. In it I need to create a function that does the following:
converts a .dwg (AutoCad) file to a .pdf file
converts a .dwg file to a .dwf file
I started with the, what I tought at the time, easier task to have the .dwg to a .pdf. After some research I found out that a way to do that (without buying a 3rd party license) is to install TrueView on the server and using it (or actually a AcCtrl.dll) to convert the file. Well, I did so. I installed the True View program and added a reference to AcCtrl Component (ACCTRLLib). Then I added a reference to the Dll inside the class file I am working on:
using ACCTRLLib;
So far so good. After that I followed the instructions on this post: PDF conversion using dwg true viewer in VB6
First, this is my code:
public static void ConvertFile()
{
IAcCtrl contrl = new AcCtrl();
contrl.PutSourcePath(#"D:\MMA\Autocat\File1.dwg");
string[] pdfPath = new string[1] { #"D:\MMA\Autocat\File1.dwg" };
contrl.SilentPublish(pdfPath);
}
Then, according to the post, I went to see if there is a registry with the specified path. The path that I have as a registry is the following:
HKEY_CURRENT_USER\Software\Autodesk\DWG TrueView\R13\DWGVIEWR-E001:409\Profiles\<<\Unnamed Profile>>\Dialogs\AcPublishDlg
So, I created a 'String Value' in it with ValueName: Location and ValueData: D:\MMA\Autocat\Testing
Alright. So, thats it. After all that I ran the application and called the function. The debugger goes through the code and everything executes (or at least looks like so) but nothing happens. I don't get a file in the D:\MMA\Autocat\Testing folder. I get no exception, no warning nothing. It just executes and nothing happens.
So what else did I tried. Some of those things might be a little naive or silly to try but nevertheless I did as I happen to be a little desperate.
I tried everything in a console application. I wasnt completely sure that this method is suitable for ASP MVC so I tried the same code with a console application unfortunatelly to the same result.
I added a file name inside the location string value. I changed the Location ValueData from 'D:\MMA\Autocat\Testing' to 'D:\MMA\Autocat\Testing\testFile.pdf' as I noticed that nowhere in the whole process a file name is asked for the converted file.
Following my thought from the previous conclusion I tried to supply the path to the 'result' file to the SilentPublish function.
string[] pdfPath = new string[1] { #"D:\MMA\Autocat\Testing\testFile.pdf" };
contrl.SilentPublish(pdfPath);
Again to no avail. So, my question, or rather questions are:
Is it possible to do it this way and if it is what am I doing wrong?
If its not than can you suggest a way?
Also if a .dwg to .dwf conversion is possible (with the same or different method I am all ears)
Thank you very much
True View does not expose the Autodesk.AutoCAD.PlottingServices namespace. You're going to need either a licensed copy of AutoCAD, RealDWG, or another third party API.
I'm not sure if you are still having this issue, but you should be able to do this with the Autodesk Forge API. Calls can be made from any language with a simple HTTP call. You will have to first convert to SVF and then to DXF and PDF from there.

MS Word Customization can't find VSTO file

I've developed a customization in Visual Studio for Word 2010 and have the solution saved in network share (using a UNC path) and the actual Word document is saved in a folder in SharePoint.
Everything works fine, users can open the document and use the customisation and when they've gone through the steps the add-on requires they click a button which saves the completed document to a different location in SharePoint. Al good. When you however now open the newly saved document from SharePoint I get the following error message:
Cannot currently access the deployment manifest at this location:
"[URL to document path in SharePoint]". You muyst set the deployment
manifest location to a UNC share or a local path when
ClickOnceAddInDeploymentManager.RunFromFolder is true.
Have done some searches on these terms but getting nothing useful! Would appreciate any help you could offer!
Try this article:
http://msdn.microsoft.com/en-us/library/vstudio/bb772100(v=vs.110).aspx
Particularly the steps under the heading:
To put the document on a server that's running SharePoint
I don't think word trusts your document after you save it in a different location.
I figured out my problem, need to give a bit more background to explain the issue a bit better.
I'm using a number of Action Panes to create a wizard-like experience for the user. When the user hits "Next" on the first pane I have code (using ThisDocument.SaveAs2) so automatically do a Save As to a specific folder in SharePoint (actually the structure gets created on the fly before it being saved).
On the final pane when they hit Finish I was running the exact same code to Save As but to the exact same location and filename and this is what seems to have caused the problem. The bottom line is that the custom property _AssemblyLocation was changed somehow in this process to only have the filename of the vsto file without an absolute path, so on re-opening the document it was looking for this file in same location.
By simply changing this to a Save instead of a Save As it now works perfectly. Took me insane amounts of time to figure that out but my own fault!

Help_File in C#

I'm using MS Visual Studio Pro 2012 and I want to create some kind of help file.
I was thinking in create a html file like this but my question is: Do I need to have the html file always in this directory, even after I have the .EXE file created or the html file is added to the .EXE file?
If not, how can it be done?
[.NET Framework 4.5 | Windows Forms]
EDIT : I want to load a given (local) html file in the default web browser. This file should be 'inside' the .EXE file.
If you're looking to build a help file from Visual Studio, why not look at:
http://shfb.codeplex.com/
Sandcastle will build your help file based on the comments you have written on your classes and methods. Hit the forward slash three times (e.g. /) above your class or method declaration and the comment box will appear. Populate with salient details, run Sandcastle, and your help file will be generated.
The advantage of having a separate HTML file is that you can update it on it's own without pushing out a new assembly. However if you want to build it into the EXE, you can go to your project properties, then click on Resources. Add an existing file (your HTML file) and it will now be accessible from your code.
When you want to open it you can do something like this
string html = Resources.MyHelpFile;
if (!File.Exists("tmpHelp.html"))
{
using (var tmpFile = File.CreateText("tmpHelp.html"))
{
tmpFile.Write(html);
}
}
Process.Start("tmpHelp.html");
You can then delete the help file at a later stage such as when the user closes your application.
I'll recommend using HTML Help Workshop to create the help file. and then use Help.ShowHelp();. Its a lot more easier
But for your case. You can either do as KeyboardP suggested or move the file to your bin/Debug folder and then use
Process.Start("helpname.html");
NOTE : You'll also need to add the file to the Application Folder when you're creating your setup.
You can build html file (I think the most easy way it's to create it via microsoft word and to save as html)
Then you make a new form contain webBrowser tool and set the URL to your html file path, like this:
string filepath = Environment.CurrentDirectory + #"\Help.htm";
Uri uri = new Uri(filepath);
webBrowser_Help.Navigate(uri);

initiating a string from a config file

I am asked to do this and I have no clue from where to start since I am new to it.
I have created a C# .NET application (a web api to be more precise) using Visual Studio 2012.
I created an lsi file ( the new version of msi files) to be able to deploy it on a server.
Now I want to create some sort of a configuration file where I can edit a string without having to go into the code every time to change it every time.
lets say the variable is called mystring:
1- how can I create a config file that request a string without having to go into the code?
2- how can I say the mystring=input string ?
I tried to look it up but since I don t have the exact name I don t really know what I am searching for ...
Thanks,
One solution would be to save a configuration file with the settings you want to load, I'd suggest saving it to the ProgramData folder.
I would save the settings to an XML file (or JSON) so you can serialize and deserialize the data into your program when it loads. Guide
You can also save other details so they'll persist each time the application is opened this way, such as a username field.

Categories